Wednesday, December 9, 2009

Why an in-home server can slow down the network

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!

2 comments:

  1. I definitely enjoyed reading it, you may be a great author.I will make sure to bookmark your blog and will often come back someday.web hosting provider

    ReplyDelete
  2. This is a good article for this specific topic.
    Info removal situation is normally an Inconvenience for the person.
    However for the simplicity of customers, scientific study has proposed a solution for situations.
    If a data removal situation has taken place, end user must know which tool or computer software to use so as to manage this condition of data files loss.
    outlook pst file recovery

    ReplyDelete