Skip to content

Instantly share code, notes, and snippets.

@jodosha
Created March 31, 2009 15:46
Show Gist options
  • Save jodosha/88239 to your computer and use it in GitHub Desktop.
Save jodosha/88239 to your computer and use it in GitHub Desktop.
ActiveRecord::SessionStore: Session vs SqlBypass
One Mongrel instance in production mode
$ ab -n 1000 -c 50 http://127.0.0.1:3000/session/read
$ ab -n 1000 -c 50 http://127.0.0.1:3000/session/write
Session
###############################################################################
### READ
Server Software:
Server Hostname: 127.0.0.1
Server Port: 3000
Document Path: /session/read
Document Length: 1 bytes
Concurrency Level: 50
Time taken for tests: 10.747 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 287004 bytes
HTML transferred: 1000 bytes
Requests per second: 93.05 [#/sec] (mean)
Time per request: 537.368 [ms] (mean)
Time per request: 10.747 [ms] (mean, across all concurrent requests)
Transfer rate: 26.08 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 1.3 0 10
Processing: 14 528 196.3 506 1149
Waiting: 11 523 195.5 501 1146
Total: 14 529 196.2 506 1149
Percentage of the requests served within a certain time (ms)
50% 506
66% 515
75% 533
80% 560
90% 667
95% 1056
98% 1143
99% 1147
100% 1149 (longest request)
### WRITE
Server Software:
Server Hostname: 127.0.0.1
Server Port: 3000
Document Path: /session/write
Document Length: 2 bytes
Concurrency Level: 50
Time taken for tests: 10.011 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 330003 bytes
HTML transferred: 2000 bytes
Requests per second: 99.89 [#/sec] (mean)
Time per request: 500.527 [ms] (mean)
Time per request: 10.011 [ms] (mean, across all concurrent requests)
Transfer rate: 32.19 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 2.4 0 12
Processing: 15 490 104.1 522 1036
Waiting: 10 485 104.6 517 1033
Total: 15 491 103.2 522 1037
Percentage of the requests served within a certain time (ms)
50% 522
66% 532
75% 536
80% 542
90% 550
95% 556
98% 567
99% 933
100% 1037 (longest request)
SqlBypass
###############################################################################
### READ
Server Software:
Server Hostname: 127.0.0.1
Server Port: 3000
Document Path: /session/read
Document Length: 1 bytes
Concurrency Level: 50
Time taken for tests: 7.531 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 287002 bytes
HTML transferred: 1000 bytes
Requests per second: 132.78 [#/sec] (mean)
Time per request: 376.571 [ms] (mean)
Time per request: 7.531 [ms] (mean, across all concurrent requests)
Transfer rate: 37.21 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.9 0 7
Processing: 11 369 83.6 349 809
Waiting: 9 366 84.1 345 807
Total: 11 370 83.4 349 810
Percentage of the requests served within a certain time (ms)
50% 349
66% 415
75% 421
80% 426
90% 435
95% 443
98% 460
99% 741
100% 810 (longest request)
### WRITE
Server Software:
Server Hostname: 127.0.0.1
Server Port: 3000
Document Path: /session/write
Document Length: 2 bytes
Concurrency Level: 50
Time taken for tests: 7.802 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 330001 bytes
HTML transferred: 2000 bytes
Requests per second: 128.17 [#/sec] (mean)
Time per request: 390.121 [ms] (mean)
Time per request: 7.802 [ms] (mean, across all concurrent requests)
Transfer rate: 41.30 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 1.1 0 8
Processing: 11 383 94.7 365 885
Waiting: 9 379 95.0 362 883
Total: 11 383 94.2 365 886
Percentage of the requests served within a certain time (ms)
50% 365
66% 432
75% 435
80% 437
90% 453
95% 560
98% 579
99% 738
100% 886 (longest request)
class SessionController < ApplicationController
def read
render :text => session[:user_id], :status => :ok
end
def write
render :text => session[:user_id] = 23, :status => :ok
end
end
# ...
ActionController::Base.session_store = :active_record_store
ActiveRecord::SessionStore.session_class = ActiveRecord::SessionStore::SqlBypass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment