{"id":3623,"date":"2025-11-19T07:10:51","date_gmt":"2025-11-19T07:10:51","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=3623"},"modified":"2025-11-19T07:10:53","modified_gmt":"2025-11-19T07:10:53","slug":"how-to-improve-server-speed","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/how-to-improve-server-speed\/","title":{"rendered":"How to Improve Server Speed"},"content":{"rendered":"\n<p>A slow server directly affects your website performance, user experience, SEO ranking, and business revenue. Whether you are running a PHP\/Laravel application, WordPress, or microservices, server slowness often happens due to overloaded databases, excessive logs, heavy sessions, or insufficient resources.<\/p>\n\n\n\n<p>In this blog, we will understand <strong>why servers become slow<\/strong>, how to <strong>identify the root cause<\/strong>, and the <strong>steps you can take to fix slowness<\/strong>, including cleaning unnecessary database tables like <code>url_clicks<\/code>, <code>sessions<\/code>, and <code>oauth_access_tokens<\/code>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>1. Why Does a Server Become Slow?<\/strong><\/h1>\n\n\n\n<p>There are multiple reasons why a server slows down:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.1 High CPU Usage<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Heavy MySQL queries<\/li>\n\n\n\n<li>Unoptimized tables<\/li>\n\n\n\n<li>Too many concurrent requests<\/li>\n\n\n\n<li>Loops or stuck queries<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.2 High RAM Usage<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Too many active PHP\/Laravel sessions<\/li>\n\n\n\n<li>Large cache or log files<\/li>\n\n\n\n<li>Memory leaks in running services<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.3 Database Bloating<\/strong><\/h3>\n\n\n\n<p>This is one of the most common reasons.<\/p>\n\n\n\n<p>Some tables grow extremely large over time:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>url_clicks<\/code> \u2192 track clicks, gets thousands of rows<\/li>\n\n\n\n<li><code>sessions<\/code> \u2192 old user sessions never cleaned<\/li>\n\n\n\n<li><code>oauth_access_tokens<\/code> \u2192 millions of expired access tokens<\/li>\n<\/ul>\n\n\n\n<p>When these tables become huge, MySQL slows down.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.4 Disk Issues<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Full disk<\/li>\n\n\n\n<li>Too many small files<\/li>\n\n\n\n<li>Huge log files<\/li>\n\n\n\n<li>Large session directories<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.5 Poor MySQL Configuration<\/strong><\/h3>\n\n\n\n<p>A default MySQL config cannot handle medium or high traffic.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>2. How to Check Why Your Server Is Slow<\/strong><\/h1>\n\n\n\n<p>Before improving speed, you must identify what is causing the slowness.<\/p>\n\n\n\n<p>Run these commands on your Linux server:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.1 Check RAM<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>free -h\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.2 Check CPU Load<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>top\n<\/code><\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>htop\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.3 Check Disk Space<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>df -h\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.4 Check MySQL Heavy Queries<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p -e \"SHOW FULL PROCESSLIST;\"\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.5 Check Which Tables Are Heavy<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT table_name AS TableName,\nROUND((data_length + index_length)\/1024\/1024, 2) AS Size_MB\nFROM information_schema.TABLES\nWHERE table_schema = 'your_database'\nORDER BY (data_length + index_length) DESC;\n<\/code><\/pre>\n\n\n\n<p>These checks clearly show whether the issue is CPU, RAM, Disk, or MySQL.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>3. Delete Unnecessary Database Records to Improve Speed<\/strong><\/h1>\n\n\n\n<p>Over time, tables like <code>url_clicks<\/code>, <code>sessions<\/code>, and <code>oauth_access_tokens<\/code> become extremely large and slow down the server.<\/p>\n\n\n\n<p>Cleaning them regularly helps in:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Reducing storage<\/li>\n\n\n\n<li>Improving SELECT queries<\/li>\n\n\n\n<li>Improving INSERT performance<\/li>\n\n\n\n<li>Speeding up backups<\/li>\n\n\n\n<li>Improving overall MySQL performance<\/li>\n<\/ul>\n\n\n\n<p>Below are the most common fixes:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>4. Cleaning <code>url_clicks<\/code> Table<\/strong><\/h1>\n\n\n\n<p>This table grows very fast if your website has analytics or click tracking.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Delete old entries (older than 4 months) \u2014 50,000 at a time<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>DELETE FROM url_clicks\nWHERE created_at &lt; NOW() - INTERVAL 4 MONTH\nLIMIT 50000;\n<\/code><\/pre>\n\n\n\n<p>Run multiple times until empty.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>5. Cleaning <code>sessions<\/code> Table<\/strong><\/h1>\n\n\n\n<p>Laravel stores sessions in the database if configured.<br>Old sessions are useless and slow down queries.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Delete sessions older than 2 days<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>DELETE FROM sessions\nWHERE last_activity &lt; UNIX_TIMESTAMP(NOW() - INTERVAL 2 DAY)\nLIMIT 20000;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Optimize table<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>OPTIMIZE TABLE sessions;\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>6. Cleaning <code>oauth_access_tokens<\/code> Table<\/strong><\/h1>\n\n\n\n<p>OAuth tokens generated by Laravel Passport accumulate very fast.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Delete tokens older than 2 days<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>DELETE FROM oauth_access_tokens\nWHERE created_at &lt; NOW() - INTERVAL 2 DAY\nLIMIT 50000;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Optimize table<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>OPTIMIZE TABLE oauth_access_tokens;\n<\/code><\/pre>\n\n\n\n<p>This improves MySQL performance dramatically.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>7. Additional Steps to Improve Server Speed<\/strong><\/h1>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>7.1 Clear Laravel Cache<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>php artisan optimize:clear\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>7.2 Restart services<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart apache2\nsudo systemctl restart mysql\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>7.3 Enable MySQL Slow Query Log<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>SET GLOBAL slow_query_log = 'ON';\nSET GLOBAL long_query_time = 1;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>7.4 Increase MySQL performance<\/strong><\/h3>\n\n\n\n<p>Adjust your <code>my.cnf<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>innodb_buffer_pool_size=2G\nquery_cache_type=1\nquery_cache_size=128M\nmax_connections=200\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>7.5 Clean large log files<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>du -sh \/var\/log\/*\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>7.6 Remove unused packages<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt autoremove\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>8. Automate Cleanup (Recommended)<\/strong><\/h1>\n\n\n\n<p>To keep your server fast permanently, create a cron job to clean old records daily.<\/p>\n\n\n\n<p>Example cron:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>0 3 * * * mysql -u root -pYourPassword -e \"DELETE FROM url_clicks WHERE created_at &lt; NOW() - INTERVAL 4 MONTH LIMIT 50000;\"\n<\/code><\/pre>\n\n\n\n<p>You can do similar cron jobs for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>sessions<\/li>\n\n\n\n<li>oauth_access_tokens<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A slow server directly affects your website performance, user experience, SEO ranking, and business revenue. Whether you are running a PHP\/Laravel application, WordPress, or microservices, server slowness&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3623","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/3623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=3623"}],"version-history":[{"count":2,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/3623\/revisions"}],"predecessor-version":[{"id":3625,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/3623\/revisions\/3625"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=3623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=3623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=3623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}