Testing Grails 1.0RC1 on a virtual server
In summary:
For those who dont want to read further, here is a quick summary. Grails has been tested on a virtual server with limited resources, where a small application with several domain object performed well under load. During these tests Tomcat was configured with 128MB maximum heap and ran without incident (tomcat was not using the entire heap). Given this I lowered the heap size to 96MB and the application continued to function well. I believe Grails may run with less memory that 96MB but I have not tested this yet. It is possible to run grails with less than 96MB of RAM see notes below.
Test Application:
In order to find out how Grails performs on a virtual host, I have generated a simple application that is linked below. This application was written using Grails 1.0 RC1. For the purpose of these tests our choice of domain was a simple (somewhat non-functional) Bookstore. Basically the application consits of a Bookstore object that contains many StockItems, each stock item links to a Book, and the book belongs to a Category. Category therefore has many books.
Test data is generated at application startup, each of 3 Categories has 100 Books. Each book has a StockItem and there is one Bookshop.
The application can be downloaded here: perftest.zip
Purpose of test:
This test is to find out how grails runs in an environment with limited memory, processor and disk - such as when hosting on a virtual server. As an output of this test we will have graphs of pages served per minute, average delay and worst case delay for several common use-cases, I will repeat the tests lowering the memory until the tests fail.
Test setup
Microsoft Vitrual PC (single processor, 600MB RAM, 800MB Swap (not used during test)).
Ubuntu Linux Version 7
MySQL 5 installed
Tomcat 6.0.14 (min heap:128M max heap: 128M)
Removed all example applications leaving just manager and perftest.
Test 1
10 concurrent users
Each user lists Book pages 1 then 2 then 3
128MB heap

Test 2
10 concurrent users
Each user lists Book page 1, then selects to show Book 1
128MB heap

Test 3
10 concurrent users
Show category 1 - this involves rendering one hundred book records, and as expected caused the most load.
128MB heap

Test 4 - lower memory
10 concurrent users
Each user lists Book pages 1 then 2 then 3
96MB heap

Notes - copied from page comments
I have another experiment results to share.
I've configured Tomcat to be a shared Grails app server. Then I've started 2 Tomcat instances, for 2 Grails apps.
At the normal load, I've found that each Grails app uses memory around 70-90 MB and the memory overhead used by OS is around 50-55 MB.
I think with this Tomcat configuration, I can run each Grails app under 96 MB limitation.
My configuration are, tweaked Tomcat 6.0.14, JDK 1.6_03, CentOS 5.
Comments (4)
Dec 11, 2007
Chanwit Kaewkasi says:
Hi Dave, I'm interested to know how many MB of swap space you've set for Ubuntu...Hi Dave,
I'm interested to know how many MB of swap space you've set for Ubuntu?
Thanks,
Chanwit
Dec 12, 2007
Dave Cherry says:
Actual swap configuration is 890M. I have checked by running the tests again, th...Actual swap configuration is 890M. I have checked by running the tests again, the swap file is not being used (still at 0K). In fact the box is not under memory strain whatsoever, has still got 182M in cache and 147M in buffer space. As I say the total requirement for tomcat including the overhead of starting the JVM is 260M, resident is about 120M.
I also have a live hosted server running Grails, this does not have swap as it is a virtualized CentOS instance. In this case I fit the application comfortably on a 700MB server. I think I could probably fit it equally well on a 512MB server without swap.
The only problem I have noted with not having swap is that a second instance of Java cannot be started to close down tomcat. This is because there is a large requirement on virtual memory to start a java instance.
Dec 12, 2007
Chanwit Kaewkasi says:
Thanks Dave, I have another experiment results to share. I've configured Tomcat...Thanks Dave,
I have another experiment results to share.
I've configured Tomcat to be a shared Grails app server. Then I've started 2 Tomcat instances, for 2 Grails apps.
At the normal load, I've found that each Grails app uses memory around 70-90 MB and the memory overhead used by OS is around 50-55 MB.
I think with this Tomcat configuration, I can run each Grails app under 96 MB limitation.
My configuration are, tweaked Tomcat 6.0.14, JDK 1.6_03, CentOS 5.
Cheers,
Chanwit
Dec 13, 2007
Dave Cherry says:
Hi, Thanks for sharing that, it is interesting. Did you consider using the...Hi,
Thanks for sharing that, it is interesting.
Did you consider using the virtual hosting functionality in tomcat to let both applications run in the same VM space? Then some of the classes can be moved into common reducing class loading. This has an enormous impact on memory as Java needs about 150M of virtual to be able to start each instance - very little is shared.
I know this is a security issue, but if you own both applications then that may not be as much of an issue. I'm interested because soon I will be in the position of managing more than one grails app on a single server. One thing I think will happen is that the permanent heap size will be exceed (64mb) and may need to be adjusted.
These comments are not visible on the main grails page, I will add them to the main article over the weekend.