How to increase SWAP file size in Ubuntu Linux 14.04 ?

July 9, 2015 1.4k views
Linux Basics WordPress Server Optimization

I have a droplet with 4 GB Memory with 8 GB SWAP file & I am getting about 23000 views on my blog , so my loading time of site is taking many seconds.

Please can someone tell me how to increase SWAP file size ?

Also please tell me how to speed up my wordpress blog (I cache with W3 Super Cache) ...

1 Answer

If you created your swap file following our tutorial you can simply do the following to disable you current swap file:

swapoff /swapfile

Then create a new one using the same procedure. There should not be any need to update your fstab.

If you are seeing a lot of requests and apache is taking a while to respond you may want to check if you have KeepAlive turned on. If you do, this will keep a connection open for a current client. If this is on and your MaxClients setting is too low a new request will wait for one of the kept-alive connections to time out before responding. If this happens you will see slow first response times but actual file transfers and php processing still running normally.

  • Hi ,

    Thanks for reply

    I increased swap file size but still facing late server response

    Can you guide me how enable KeepAlive & check MaxClients settings.
    A tutorial will be highly appreciated.

    Thanks in advance

  • You can find these values in /etc/apache2/apache2.conf

    You can either turn off KeepAlive or reduce the timeout. This will prevent threads from being kept open preventing new requests from being served. Otherwise they have to wait for the current connections to time out to complete their connections.

    # KeepAlive: Whether or not to allow persistent connections (more than
    # one request per connection). Set to "Off" to deactivate.
    KeepAlive On
    # MaxKeepAliveRequests: The maximum number of requests to allow
    # during a persistent connection. Set to 0 to allow an unlimited amount.
    # We recommend you leave this number high, for maximum performance.
    MaxKeepAliveRequests 100
    # KeepAliveTimeout: Number of seconds to wait for the next request from the
    # same client on the same connection.
    KeepAliveTimeout 5

    If you are using Apache 2.4 which should be the case on Ubuntu 14.04 the MaxClients directive is no longer required.

Have another answer? Share your knowledge.