My previous project W is an in-mature system. The reasons are:
1. poor designed. Application server(JBoss), database(postgres), web server(Apache Httpd) are located in ONE machine.
2. no design document at all.
3. no test cases.
Here we only talk about point 1.
Although the machine is a powerful one, it cannot host more than 5 simultaneous requests.
I was asked to put the database to a second machine and at the same time do some tuning against the application server.
Using the suggested GC policy settings (These settings can be found in http://bit.ly/17dwBVM)
Uses an improved collection algorithm that takes advantage of multiple processor cores to sweep the young generation. Since this is a stop-the-world phase of garbage collection, performance is improved if the collector uses multiple CPU cores while collecting the young generation.
Enables the Concurrent Mark Sweep (CMS) algorithm to be used for managing the old generation. This algorithm is mostly, but not entirely, concurrent, and can eliminate or reduce the frequency of full stop-the-world collections.
Enables multiple parallel threads to participate in the remark phase of the CMS algorithm. Since this is a stop-the-world phase, performance is improved if the collector uses multiple CPU cores while collecting the old generation.
HTTP persistent connection
HTTP persistent connection, also called HTTP keep-alive, or HTTP connection reuse, is the idea of using the same TCP connection to send and receive multiple HTTP requests/responses, as opposed to opening a new connection for every single request/response pair.
• Less CPU and memory usage (because fewer connections are open simultaneously)
• Enables HTTP pipelining of requests and responses
• Reduced network congestion (fewer TCP connections)
• Reduced latency in subsequent requests (no handshaking)
• Errors can be reported without the penalty of closing the TCP connection
However, this keeps the httpd instance or thread busy for the duration of the requests until the timeout expires after the last request. Therefore high traffic sites tend to keep the KeepAlive feature off or the timeout very short. Small sites, and those with more page elements to load, provide better performance to individual users by having KeepAlive on.
To implement this, switch the parameter KeepAlive to on, in the httpd.conf file.To implement this, switch the parameter KeepAlive to on, in the httpd.conf file.(This file can be found in the Apache Httpd server)
1. Create index (I am surprised there is no index against any table)
2. Increase the effective_cache_size settings from 128m to 2g in postgresql.conf(effective_cache_size should be set to an estimate of how much memory is available for disk caching by the operating system and within the database itself. If it’s set too low, indexes may not be used for executing queries the way you’d expect.Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting.)
Optimize the code to put some frequent query into emchache.
After the tuning and migration, the W system can handle at least 15 simultaneous requests, although it is still very limited. At least it can match the current requirement.
What is the next step? I think we should consider Jboss Cluster.