Skip to content

levicook/goliath-postgres-spike

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is a proof of concept designed to confirm the viability of accessing PostreSQL from Goliath, in a non-blocking fashion.

Goals Met:

  1. Make sure that blocking database operations, like "select pg_sleep(1)", don't interfere with our ability to accept and respond to http requests.

  2. Limit, without blocking, the number of database connections we're holding open.

  3. Don't crash in a giant ball of fire under minor load.

Running the demo server

  1. Make sure you have postgres running locally

  2. Make sure you have ruby 1.9.x and bundler installed

  3. Clone the project, bundle, etc.

  4. Launch the server $ ./api --port=9000 --verbose [75693:INFO] 2012-03-15 15:23:06 :: Starting server on 0.0.0.0:9000 in development mode. Watch out for stones

  5. Confirm it's basically working $ time curl -i localhost:9000 HTTP/1.1 200 OK Content-Type: text/plain Content-Length: 8 Server: Goliath Date: Thu, 15 Mar 2012 21:28:12 GMT

    pg_sleep real 0m1.025s user 0m0.002s sys 0m0.003s

Resources:

  • PostgreSQL

  • Goliath -- Rubyists should really spend more time with this project.

  • EM::Synchrony -- Because it makes node.js kids jealous.

  • EM::Postgres -- I was especially glad to run into this project, as it's exactly what I was expecting to have to implement on my own.

  • OldMoe -- Dated, but very interesting work on non-blocking database IO. Really highlights the fundamental reasons for pursuing this architecture.

  • StackOverflow -- Because I had the same basic question.

Results

#----------------------------------------------------------------------
$ ab -d -S -n30 -c5 http://localhost:9000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software:        Goliath
Server Hostname:        localhost
Server Port:            9000

Document Path:          /
Document Length:        8 bytes

Concurrency Level:      5
Time taken for tests:   6.045 seconds
Complete requests:      30
Failed requests:        0
Write errors:           0
Total transferred:      3780 bytes
HTML transferred:       240 bytes
Requests per second:    4.96 [#/sec] (mean)
Time per request:       1007.507 [ms] (mean)
Time per request:       201.501 [ms] (mean, across all concurrent requests)
Transfer rate:          0.61 [Kbytes/sec] received

Connection Times (ms)
              min   avg   max
Connect:        0     0    0
Processing:  1003  1006 1015
Total:       1003  1006 1015

#----------------------------------------------------------------------
$ ab -d -S -n30 -c10 http://localhost:9000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software:        Goliath
Server Hostname:        localhost
Server Port:            9000

Document Path:          /
Document Length:        8 bytes

Concurrency Level:      10
Time taken for tests:   6.022 seconds
Complete requests:      30
Failed requests:        0
Write errors:           0
Total transferred:      3780 bytes
HTML transferred:       240 bytes
Requests per second:    4.98 [#/sec] (mean)
Time per request:       2007.397 [ms] (mean)
Time per request:       200.740 [ms] (mean, across all concurrent requests)
Transfer rate:          0.61 [Kbytes/sec] received

Connection Times (ms)
              min   avg   max
Connect:        0     0    0
Processing:  1004  1838 2020
Total:       1004  1838 2020

About

proof of concept ~ goliath accessing postgres asynchronously

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published