What does MySQL overloading mean

One of the limits InfinityFree enforces is how much you can stress the MySQL database server. This article explains what overloading MySQL means and how you can control it.

What does overloading MySQL mean?

Most dynamic websites use a database to store dynamic data, like posts, comments, products, accounts and so on. This data is stored on database servers. Your website can then interact with the database to see and modify the data stored in the database.

The database server needs to do work to supply and change the data you entered through it. Most dynamic websites have to execute many queries for every page which is requested, so it’s very important for a database server to be fast, or it would slow down your website a lot.

In order to keep the server load down on the database servers (and keep the websites using it zippy), InfinityFree frequently checks the load on the server. If it’s determined that the database server load is too high - and performance on the websites using it is reduced - an automated system will come into action.

The system will then check which users on the database server use the most database server power. The system will then suspend the accounts causing the highest stress for the database server, which will be taken down for 24 hours.

This system ensures that the database load stays low so the websites using the database will be fast.

How could my website overload the database server?

There are a many different factors which could cause high database load from your application. A few common issues are:

  • Your website received a lot of hits, which results in a large number of connections to the database being opened, as well as a large number of database queries to be executed.
  • Your website code executes a lot of database queries for every request.
  • Some of the database queries you execute take a lot of processing power to execute. Queries which process a lot of data, have complex subqueries and joins, or which just don’t use indexes properly, can put a lot of strain on a database.

How do I reduce my database load?

If you use existing software and don’t write the database queries yourself, here are some tips to help reduce your database usage (and make your website load faster in the process):

  • Remove unnecessary plugins and scripts from your website. Most plugins and addons all execute their own queries, so the less software you have, the less database queries are executed.
  • Install caching on your website, so commonly used data doesn’t need to be retrieved for every request.

If you’ve written the MySQL queries yourself, here are some tips to help optimize them:

  • Ensure you create only one database connection per request, and use it for all queries. Reusing a single database connection is faster and lighter than creating a new database connection for every query.
  • Try to avoid running large database bulk jobs, like big analytics queries or imports. Web hosting database servers are optimized for constant, light usage, not for performing big data analysis.
  • Try using the EXPLAIN function of MySQL in phpMyAdmin to test if queries are running optimally. If it turns out your queries are reading a lot of rows, you can try to add indexes, restructure the SQL query or change your database layout so the data can be retrieved more efficiently.

The tips above don’t work for me, how do I keep my website online?

If your memory usage is still too high after following the recommendations above (or you are having trouble applying the tips to your website), please consider to upgrade your account to premium hosting.

With premium hosting, the database usage limits are far higher than with free hosting, so your website can continue to grow. Add to that the other great features of premium hosting, like free SSL certificates, Cloudflare RailGun and an award winning cloud hosting platform, and you can be sure your website will stay fast and reliable.

1 Like