How many objects does a Rails request allocate? Here are Twitter's numbers:
- API: 22,700 objects per request
- Website: 67,500 objects per request
- Daemons: 27,900 objects per action
I want them to be lower. Overall, we burn 20% of our front-end CPU on garbage collection, which seems high. Each process handles ~29,000 requests before getting killed by the memory limit, and the GC is triggered about every 30 requests.
In memory-managed languages, you pay a performance penalty at object allocation time and also at collection time. Since Ruby lacks a generational GC (although there are patches available), the collection penalty is linear with the number of objects on the heap.
a note about structs and immediates
In Ruby 1.8, Struct instances use fewer bytes and allocate less objects than
Hash and...
October 21, 2009
