Even with the best (in-home) technologies, the server can hog your home network, and bring everything down to a crawl. Case in point, my 5MBPS connection started to feel like dialup, as I browsed in slow motion.
How can this happen? And how do you prevent this?
High active ip connections.
Here is what can happen with a poorly configured server:
Let's say you setup a Linksys WRT-64G router which you use at home, with your new webserver on a lan port. Over time, your server will establish new connections with users (based on the apache settings). These connections, and the router timeout limits, can severely hamper the overall network performance.
The reason? Connections aren't killed after they are used. And the router runs out of memory trying to keep track of all the connections.
The really odd symptom, is that when you open a new browser window, it struggles to connect to a website. But your other windows are running better.
Here is a simple remedy to the problem:
1. Router setting changes:
First lets check if your router is complaining:
a. Check in your router status page for the number of Active ip connections. Typically this should not be more than 30 per computer using the router.
b. If the Active ip connections, are high (500+), then check if most of the active connections are from your server (in dd-wrt, you can do this by going to Status > Click on the number against 'Active IP Connections'.
c. If you find it is your server, you've hit jackpot. Time to set things straight:
Set the router to terminate unnecessary persistent connections.
You can do this by reducing the TCP and UDP timeouts (I recommend TCP timeout 600 seconds and UDP timeout 120 seconds).
This will prevent the router from keeping unnecessary connections on.
2. Server setting changes:
Apache likes to setup a lot of connections so you get a decent amount of multi-user performance from your website. If yours is a new website, likely it will take time to get bombarded by too many users.
Given that you want to share your home network with your server, these settings will help reduce the demand from the server:
a. Go to the apache config file (in ubuntu, it is: /etc/apache2/apache2.conf), and modify the mpm worker and preform modules as follows. (If you already have the same Server settings, then considering reducing them further)
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 100
MaxRequestsPerChild 500
</IfModule>
<IfModule mpm_worker_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
b. Restart your apache server (in Ubuntu: sudo apache2ctl restart)
That's it! And your apache server will run much lighter now - especially with fewer extra servers lurking around.
3. Check if everything looks good:
You should now see a drop in number of active ip connections.
Also, soon your in-home network will get back to its peppy self.
I hope this helps you!
Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts
Wednesday, December 9, 2009
Thursday, November 5, 2009
Apache MySQL Performance dip
Separating the MySQL and Apache servers has slowed my site down, instead of speeding it up! Any suggestions?
I have hosted a LAMP website on a 2GHz AMD Opteron server running with 2GB of RAM.
As the data needs grew, the MySQL database seemed to need its own area, and could not serve the apache server fast enough.
So I split the MySQL database to run on its own 2GHz AMD Opteron/2GB RAM server - with a single-hop connection between the two of them at the data center.
But performance has dipped - any clicks take a much longer time to show a result from the database.
Any ideas how to get better performance from the separate Apache/MySQL server setup?
Thanks!
I have hosted a LAMP website on a 2GHz AMD Opteron server running with 2GB of RAM.
As the data needs grew, the MySQL database seemed to need its own area, and could not serve the apache server fast enough.
So I split the MySQL database to run on its own 2GHz AMD Opteron/2GB RAM server - with a single-hop connection between the two of them at the data center.
But performance has dipped - any clicks take a much longer time to show a result from the database.
Any ideas how to get better performance from the separate Apache/MySQL server setup?
Thanks!
Tuesday, October 6, 2009
LAMP Server Crash
If you did some optimizations by adding memory or RAM to processes, and the next morning, you find your server is no longer online: chances are it ran out of space and triggered the oom-killer.
oom-killer is a process that goes randomly killing processes to help the system survive.
After this occurs you should always restart as soon as possible.
Here is where you can find the logs in ubuntu, and how to identify if your system shutdown because of memory:
location of log: /var/log/messages (you will have to have super user permissions to view)
What you'll see: Just before the server shutdown or went erratic, this message:
apache2 invoked oom-killer
To get out of this situation, try to put more conservative memory settings on your applications, or add more RAM!
All the best!
oom-killer is a process that goes randomly killing processes to help the system survive.
After this occurs you should always restart as soon as possible.
Here is where you can find the logs in ubuntu, and how to identify if your system shutdown because of memory:
location of log: /var/log/messages (you will have to have super user permissions to view)
What you'll see: Just before the server shutdown or went erratic, this message:
apache2 invoked oom-killer
To get out of this situation, try to put more conservative memory settings on your applications, or add more RAM!
All the best!
Subscribe to:
Posts (Atom)