Active Record performance

81 views
Skip to first unread message

Thiago Lewin

unread,
Sep 16, 2013, 6:19:40 PM9/16/13
to golia...@googlegroups.com
Hi,

  I am working on Goliath app version for Web Framework Benchmarks, just for fun.
  Some parts of benchmark ask for ORM version or if you decided not use it, you must have explicit it by adding a raw in front of it. I decided to keep both approaches in the same test, just for simplicity, but when I include the ORM version (ActiveRecord) I realized the general performance was compromised.
  I create a simple example to investigate the process: https://gist.github.com/tlewin/6587233
  When I run a simple benchmark (ab -n 1000 -c 10 http://localhost:9000/), I get the following results:

Concurrency Level:      10
Time taken for tests:   3.214 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      104208 bytes
HTML transferred:       11022 bytes
Requests per second:    311.18 [#/sec] (mean)
Time per request:       32.136 [ms] (mean)
Time per request:       3.214 [ms] (mean, across all concurrent requests)
Transfer rate:          31.67 [Kbytes/sec] received
  
  When I uncomment the second line, I mean, when I just include the ActiveRecord gem, I get the following results:

Concurrency Level:      10
Time taken for tests:   6.300 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      104312 bytes
HTML transferred:       11033 bytes
Requests per second:    158.74 [#/sec] (mean)
Time per request:       62.996 [ms] (mean)
Time per request:       6.300 [ms] (mean, across all concurrent requests)
Transfer rate:          16.17 [Kbytes/sec] received 

  I couldn't understand what is going on. I start to read the AR code, but it is not an easy task and will take some time.
  Does anyone have a clue what is happening?
  I ran the benchmarks with Ruby 2.0.0/ Goliath 1.0.3 on a macbook pro.

Regards,
Thiago

Ilya Grigorik

unread,
Sep 16, 2013, 11:29:28 PM9/16/13
to golia...@googlegroups.com
That's bizarre. Profile it, see where the times goes.

Also, make sure you're running goliath server with "prod" flag (-e prod) --
otherwise you'll be reloading code on every request.

ig


--
You received this message because you are subscribed to the Google Groups "Goliath.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to goliath-io+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thiago Lewin

unread,
Sep 17, 2013, 10:06:29 AM9/17/13
to golia...@googlegroups.com
I was in dev mode :-( 
I repeated the benchmark several times, trying to remove any noise, now using "ab -n 10000 -c 100 http://localhost:9000" and the version without AR inclusion is about 15% faster.

Whitout AR:

Concurrency Level:      100
Time taken for tests:   5.092 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      1040000 bytes
HTML transferred:       110000 bytes
Requests per second:    1963.96 [#/sec] (mean)
Time per request:       50.918 [ms] (mean)
Time per request:       0.509 [ms] (mean, across all concurrent requests)
Transfer rate:          199.46 [Kbytes/sec] received

With AR:

Concurrency Level:      100
Time taken for tests:   6.035 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      1040624 bytes
HTML transferred:       110066 bytes
Requests per second:    1656.87 [#/sec] (mean)
Time per request:       60.355 [ms] (mean)
Time per request:       0.604 [ms] (mean, across all concurrent requests)
Transfer rate:          168.38 [Kbytes/sec] received

I will profile it in detail, as you suggested, but my guess is the overhead of number of objects created by AR implies in more GC calls.
Many thanks!

Thiago
Reply all
Reply to author
Forward
0 new messages