Can I get your affiliate link to your host? I wish my website loaded up as fast as yours lol. How To Configure nginx as reverse proxy… June 26, How to install PgAdmin 4 on Ubuntu… June 14, Automation Tool. Region does not seem to be available… May 11, How to deploy Jenkins using Docker Compose May 27, How to Install Jenkins on Ubuntu How to Integrate Rundeck with Active directory… March 3, Teamspeak 3 : Guide and Review January 9, We can use the free utility again to corroborate our findings:.
Our swap file is enabled at the moment, but when we reboot, the server will not automatically enable the file for use. We can change that by modifying the fstab file, which is a table that manages filesystems and partitions.
At the bottom of the file, you need to add a line that will tell the operating system to automatically use the swap file that you created:. When you are finished adding the line, you can save and close the file.
The server will check this file on each bootup, so the swap file will be ready for use from now on. These configurations are optional in most cases, and the changes that you make will depend on your application needs and your personal preference.
The swappiness parameter determines how often your system swaps data out of memory to the swap space. This is a value between 0 and that represents the percentage of memory usage that will trigger the use of swap. With values close to zero, the system will not swap data to the drive unless absolutely necessary.
Telling the system not to rely on the swap as much will generally make your system faster. Values that are closer to will try to put more data into swap in an effort to keep more memory free. We can see the current swappiness value by reading the swappiness configuration file:. CentOS 7 defaults to a swappiness setting of 30, which is a fair middle ground for most desktops and local servers. We can set the swappiness to a different value by using the sysctl command.
For instance, to set the swappiness to 10, we could type:. This setting will persist until the next reboot. To make the setting persist between reboots, we can add the outputted line to our sysctl configuration file:. The server will now automatically set the swappiness to the value you declared on each bootup.
This setting affects the storage of special filesystem metadata entries. You can see the current value of this cache pressure by querying the proc filesystem again:.
As it is currently configured, our system removes inode information from the cache far too quickly. We can set this to a more conservative setting, like 50, by using sysctl :. Again, this is only valid for our current session. We can change that by adding it to our configuration file, like we did with our swappiness setting:. The server will now automatically set the cache pressure to the value you declared on each bootup. By following the steps in this guide, you will have given your server some breathing room in terms of memory usage.
Swap space is incredibly useful in avoiding some common problems. If you are running into OOM out of memory errors, or if you find that your system is unable to use the applications that you need, the best solution is to optimize your application configurations or upgrade your server. However, configuring swap space can give you more flexibility and can help buy you time on a less powerful server.
Where would you like to share this to? Twitter Reddit Hacker News Facebook. Read More…. Prerequisites Must have free space on mounted disk. You can check by using df -Th command.
Now mount the swap area, run below given command. Enable the swap area swapon -a 7. Check the number swap space mounted on your system swapon -s 8. To check how much is swap space available on system.
0コメント