Amazon EC2 instance comparison small vs medium

I’ve been working on a blog post on more EC2 stuff for a while now, but it grew too big, too much text. So I’ll break it up in small pieces and post what I feel for. The first thing out is a highly unscientific, but illustrative comparison of the difference between a the cheapest (small) and the second cheapest (medium) EC2 instance available at AWS. It should be obvious out of the technical specification of the instances, but many people are slow, like me.

What’s installed on the instances being tested?

  • nginx w/passenger installed
  • ruby 1.8.6 and rails 2.3.4
  • sqlite3
  • my rails app
  • ubuntu

OK, there is a lot to do to improve performance and the most efficient is always to improve the ruby code! My code used here is really crap, perfect for this example! I’ve got an index method designed for displaying, say 10, records, with internationalization on the time and so forth. With 295 times more records than that, almost 3000 records, the code performs really bad. Enough self-criticism, to the test:

instance OS result 1 result 2
medium ubuntu hardy (8.04) Completed in 7613ms (View: 7440, DB: 151) Completed in 7800ms (View: 7653, DB: 144)
small ubuntu karmic (9.10) Completed in 20522ms (View: 20216, DB: 302) Completed in 21690ms (View: 21389, DB: 296)
small ubuntu hardy (8.04) Completed in 18164ms (View: 17757, DB: 339) Completed in 18362ms (View: 18044, DB: 315)

Not very scientific meaning that I did this only two times for each one, but they were all fresh instances. The second time around I had a few more entries. The results are taken from the production.log after each request.

Observations

Observation 1 One thing to notice is that the DB operation is pretty fast, loading them into memory in 0.15 to 0.4 sec, while rendering the view takes 7.4 to 20 secs. It’s up to 70 times faster/slower.

Observation 2 The tests indicates that ubuntu hardy (8.04) performs slightly better than ubuntu karmic koala (9.10)

Observation 3 the medium instance, named High CPU instance by Amazon, performed about 2-3 times better than the small. Not surprisingly as the small instance has 1 EC2 compute unit (1 EC2 is slightly more than 1 GHz) while the medium have 2.5 Ec2 compute units. Well, actually it’s a dual and have 2x 2.5Ec2 compute units, but as rails apps are single threaded, it’s not being utilized.

Conclusion

If you’re close to putting your app in production or it is in production, the near to 3 times improved performance is definitely worth the about 35% added cost. It would be stupid to scale up by launching more small instances.

Appendix

Finally, for fun, these are the prices and specs for european instances at amazon:

Instance types

Small Instance (Default) 1.7 GB of memory, 1 EC2 Compute Unit (1 virtual core with 1 EC2 Compute Unit), 160 GB of local instance storage, 32-bit platform

High-CPU Medium Instance 1.7 GB of memory, 5 EC2 Compute Units (2 virtual cores with 2.5 EC2 Compute Units each), 350 GB of local instance storage, 32-bit platform

prizing

EU – Ireland
Standard On-Demand Instances Linux/UNIX Usage Windows Usage
Small (Default) $0.095 per hour $0.12 per hour
Large $0.38 per hour $0.48 per hour
Extra Large $0.76 per hour $0.96 per hour
High-Memory On-Demand Instances Linux/UNIX Usage Windows Usage
Double Extra Large $1.34 per hour $1.44 per hour
Quadruple Extra Large $2.68 per hour $2.88 per hour
High-CPU On-Demand Instances Linux/UNIX Usage Windows Usage
Medium $0.19 per hour $0.29 per hour
Extra Large $0.76 per hour $1.16 per hour

About Ole Morten Amundsen

Developer, programmer, entrepreneur. Java, .Net, ruby, rails, agile, lean. Opinionated enthusiast!
This entry was posted in cloud computing and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s