MOTOSHARE ๐Ÿš—๐Ÿ๏ธ
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
๐Ÿš€ Everyone wins.

Start Your Journey with Motoshare

How to Improve Server Speed

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.

In this blog, we will understand why servers become slow, how to identify the root cause, and the steps you can take to fix slowness, including cleaning unnecessary database tables like url_clicks, sessions, and oauth_access_tokens.


1. Why Does a Server Become Slow?

There are multiple reasons why a server slows down:

1.1 High CPU Usage

  • Heavy MySQL queries
  • Unoptimized tables
  • Too many concurrent requests
  • Loops or stuck queries

1.2 High RAM Usage

  • Too many active PHP/Laravel sessions
  • Large cache or log files
  • Memory leaks in running services

1.3 Database Bloating

This is one of the most common reasons.

Some tables grow extremely large over time:

  • url_clicks โ†’ track clicks, gets thousands of rows
  • sessions โ†’ old user sessions never cleaned
  • oauth_access_tokens โ†’ millions of expired access tokens

When these tables become huge, MySQL slows down.

1.4 Disk Issues

  • Full disk
  • Too many small files
  • Huge log files
  • Large session directories

1.5 Poor MySQL Configuration

A default MySQL config cannot handle medium or high traffic.


2. How to Check Why Your Server Is Slow

Before improving speed, you must identify what is causing the slowness.

Run these commands on your Linux server:

2.1 Check RAM

free -h

2.2 Check CPU Load

top

or

htop

2.3 Check Disk Space

df -h

2.4 Check MySQL Heavy Queries

mysql -u root -p -e "SHOW FULL PROCESSLIST;"

2.5 Check Which Tables Are Heavy

SELECT table_name AS TableName,
ROUND((data_length + index_length)/1024/1024, 2) AS Size_MB
FROM information_schema.TABLES
WHERE table_schema = 'your_database'
ORDER BY (data_length + index_length) DESC;

These checks clearly show whether the issue is CPU, RAM, Disk, or MySQL.


3. Delete Unnecessary Database Records to Improve Speed

Over time, tables like url_clicks, sessions, and oauth_access_tokens become extremely large and slow down the server.

Cleaning them regularly helps in:

  • Reducing storage
  • Improving SELECT queries
  • Improving INSERT performance
  • Speeding up backups
  • Improving overall MySQL performance

Below are the most common fixes:


4. Cleaning url_clicks Table

This table grows very fast if your website has analytics or click tracking.

Delete old entries (older than 4 months) โ€” 50,000 at a time

DELETE FROM url_clicks
WHERE created_at < NOW() - INTERVAL 4 MONTH
LIMIT 50000;

Run multiple times until empty.


5. Cleaning sessions Table

Laravel stores sessions in the database if configured.
Old sessions are useless and slow down queries.

Delete sessions older than 2 days

DELETE FROM sessions
WHERE last_activity < UNIX_TIMESTAMP(NOW() - INTERVAL 2 DAY)
LIMIT 20000;

Optimize table

OPTIMIZE TABLE sessions;

6. Cleaning oauth_access_tokens Table

OAuth tokens generated by Laravel Passport accumulate very fast.

Delete tokens older than 2 days

DELETE FROM oauth_access_tokens
WHERE created_at < NOW() - INTERVAL 2 DAY
LIMIT 50000;

Optimize table

OPTIMIZE TABLE oauth_access_tokens;

This improves MySQL performance dramatically.


7. Additional Steps to Improve Server Speed

7.1 Clear Laravel Cache

php artisan optimize:clear

7.2 Restart services

sudo systemctl restart apache2
sudo systemctl restart mysql

7.3 Enable MySQL Slow Query Log

SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 1;

7.4 Increase MySQL performance

Adjust your my.cnf:

innodb_buffer_pool_size=2G
query_cache_type=1
query_cache_size=128M
max_connections=200

7.5 Clean large log files

du -sh /var/log/*

7.6 Remove unused packages

sudo apt autoremove

8. Automate Cleanup (Recommended)

To keep your server fast permanently, create a cron job to clean old records daily.

Example cron:

0 3 * * * mysql -u root -pYourPassword -e "DELETE FROM url_clicks WHERE created_at < NOW() - INTERVAL 4 MONTH LIMIT 50000;"

You can do similar cron jobs for:

  • sessions
  • oauth_access_tokens

Related Posts

Common Challenges in AWS Data Engineering and Solutions

As an industry veteran who has navigated the evolution from on-premise server racks to serverless cloud architectures, I have witnessed a massive shift. Companies are no longer…

ERP vs CRM โ€“ Whatโ€™s the Real Difference?

In the world of business software, two terms are often confused: ERP (Enterprise Resource Planning)CRM (Customer Relationship Management) Many companies assume they are similar. Some even believe…

What is AWS Certified Security Specialty (SCS-C02) and How to Crack It

In the current technology landscape, migrating to the cloud is no longer an option for most businesses; it is an inevitability. As workloads move to AWS, the…

HIS vs EHR โ€“ Are You Using the Right Healthcare System?

Digital transformation in healthcare is accelerating rapidly. Hospitals, clinics, and healthcare startups are investing heavily in technology to improve efficiency, patient care, and operational control. However, one…

Scaling Laravel for High Traffic

When your Laravel application starts growing, traffic is no longer just a number โ€” it becomes a test of architecture. Many teams think scaling means โ€œupgrading the…

Beginner to Advanced Guide to AWS Certified DevOps Professional Training

In the early days of my career, managing a data center meant physical cables and loud cooling fans. Today, those physical rooms have been replaced by lines…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x