I'm running Tomcat 5.5 on a 2x2.80GHz CPU Windows Server 2003. Apache
Httpd is also installed on the same server and is talking to my Tomcat
using mod_jk. Tomcat is only serving JSP pages where as all the
static content is served by Apache Httpd. My system is getting around
10hits per second and I have approximately 180 virtual hosts setup
both on my Tomcat and Apache Httpd serving the same application. My
application is pretty much database driven and it is optimized very
well using connection pooling and query caching. Although my
application is generally very very fast, sometimes, it hangs (once
every 20 clicks or so). I'm suspecting that I need more RAM.
Currently, I have 2GB of memory. I'm running my Tomcat with the
-Xms1024m -Xmx1024m -XX:MaxPermSize=128m -XX:MaxNewSize=48m
-XX:NewSize=48m -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled
-XX:+UseConcMarkSweepGC options. On the "processes" tab of my Windows
task manager, when I view the Mem Usage of my Tomcat (java.exe) I see
that 275MB is on RAM and 1.2GB is on VM. At the same time, my
Apache.exe is using 68MB of RAM and 73MB of VM. However, when I go to
the "Performance" tab, I see that there is still 1GB of Physical
Memory available. I have already used visualgc to take a look at my
garbage collection, and it seems OK.
ThreadsPerChild of my Apache is set to 1920. Here is one part of my
workers.properties:
worker.c1a.port=8009
worker.c1a.host=127.0.0.1
worker.c1a.type=ajp13
worker.c1a.cachesize=1920
worker.c1a.cache_timeout=600
worker.c1a.recycle_timeout=600
worker.c1a.socket_timeout=300
worker.c1a.lbfactor=1
worker.c1a.connect_timeout=0
worker.c1a.prepost_timeout=0
worker.c1a.reply_timeout=15000
Here is my Tomcat connector config:
maxThreads="1920" minSpareThreads="50" maxSpareThreads="500" acceptCount="0"
My question is very straight forward: How much memory do I need on
this particular server with my current load? I really need a
mathematical way of calculating this for scalibility and all other
purposes. If I need more memory (because of the fact that Tomcat and
Apache Httpd is mostly using VM), why is it that Windows still has 1GB
of Physical Memory available? I would expect Windows to allocate that
extra memory to my Tomcat and Apache Httpd. Would playing around with
Windows Paging File Performance settings help? |
Request for Question Clarification by
sublime1-ga
on
04 Jul 2005 22:21 PDT
aw3some...
I wouldn't have a clue how to go about calculating optimal RAM
installation on a scalable basis, based on your load statistics,
but if, in fact, you have 1GB of Physical Memory available, you
certainly have more than you need.
I would experiment with the following tweak to see if it makes
a difference for you:
Start -> Run -> Sysedit
Add the following entry to the System.ini file under [386enh]:
ConservativeSwapfileUsage=1
Let me know where this takes you...
sublime1-ga
|
Request for Question Clarification by
sublime1-ga
on
04 Jul 2005 22:23 PDT
P.S. Don't forget to reboot... ; )
|
Clarification of Question by
aw3some-ga
on
05 Jul 2005 06:01 PDT
Dear sublime1,
Thank you for your suggestion. I added the suggested line to our
system.ini and restarted the server. Unfortunately, I still have the
same numbers. I totally understand that I already have around 1GB of
available memory; however on the other hand, I still don't understand
why my Tomcat uses about 5 times as much VM compared to main memory.
After the restart, I currently have 175MB main memory and 1.1GB of VM
for my Tomcat. I'm already using my Tomcat with the -Xms1024m
-Xmx1024m options. My Apache usually needs around 250MB as well
adding it up to around 1250MB of RAM. Is there any other way I could
tell my Windows to use main memory for these two applications? After
all, this is a server and these are the only two applications
running...
On another note... When I go to the Advanced Performance Options, I
see that processor scheduling is optimized for background services
(instead of programs), memory usage is optimized for programs (instead
of system cache) and the paging size is currently 2047MB with the
"System managed size" option selected. Would it be wise to set a
custom VM size? If yes, what should be my minimum initial size? I'm
hoping my server to use more RAM by decreasing my VM size, but I'm not
sure if this is a good idea...
Asim
|
Request for Question Clarification by
sublime1-ga
on
05 Jul 2005 13:41 PDT
Asim...
When you allow Windows to manage your swapfile in Server 2003,
it uses an amount proportional to the amount of RAM installed
on the system. See under "Hardware Requirements for Windows
Server 2003 Standard Edition":
http://www.mcmcse.com/microsoft/guides/win2003_RC2.shtml
Most discussions on swapfile size recommend using space equal
to 2-2.5X the size of your installed RAM, placing the paging
file on a separate, newly defragmented drive (your fastest one)
if possible, and setting the minimum and maximum sizes the same,
which prevents the system from resizing and keeps the file
defragmented. See "Seize control of your memory":
http://64.233.179.104/search?q=cache:nWUcw5-_gEQJ:pctoday.com/Editorial/article.asp%3Farticle%3Darticles/2003/t0102/17t02/17t02.asp%26guid%3D+%22use+ram%22+custom+paging+file&hl=en
The article above offers some other options for disabling kernel
paging, and Disable-PagingExecutive, as well, in the section
"Extract the kernel (Win2000/WinXP)", and notes: "To be safe,
create an Emergency Repair Disk (Win2000) or a Restore Point
(WinXP) before you edit Registry settings".
Other opinions suggest that "If you are sure you will never need
more than 1.6 Gig then you don't need a swap file", but another
post warns that:
"Not leaving a part of page file on your boot volume means your
system cannot create a crash dump file (memory.dmp) for more info
see "Configuring Page Files for Optimisation and Recovery"
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B197379
That last Microsoft article is specific to Server 2003, and suggests
multiplying RAM by 1.5 and using two swapfiles - one on the boot
partition, and one on a separate drive and partition (a fast one),
noting that Windows will then use the fastest one available.
See this page for the full discussion:
http://www.experts-exchange.com/Operating_Systems/WinXP/Q_21258321.html
On the other hand, I suppose you could try eliminating the paging
file altogether, and in System Properties -> Advanced -> Startup
and Recovery -> System Failure -> Write Debugging Information, set
it to none, for no dump file. I haven't tried this, so I can't say
how well it would work.
My own paging file is about 1.5X my RAM, but I'm not running a
server - just Windows 2000.
This doesn't constitute an official answer, just some thoughts
to get you going.
sublime1-ga
|