My biggest site, friendship-bracelets.net, went down two times this summer (I hope it’ll stay up now). I’ll tell you some more about what happened.
On the 7th of July, my web host One.com suddenly shut my account down. Their reason was that my site loaded their servers too much. They told me that they have several customers per server machine and that my site affect these other customers by slowing their sites down. They did not tell me much about how I could change my site to make it load the servers less, but I knew that the MySQL part of the site was quite heavy. You might remember this scary message:
User friendship_brac has already more than 'max_user_connections' active connections
So, what did I do? I quickly googled some swedish web hosts that were quite cheap but had better performance than One.com’s servers. The best result I got was Binero.se. I got an account and I could upload the site immediately. Sweet.
For a few days the site could be reached via the Binero preview address, friendship-bracelets.net.preview.binero.se, since the domain transfer took way too long time than the users wanted to wait.
The 22th of July, Binero.se shut me down. Why? Too much load on the servers. Surprise surprise. I tried, really tried to optimize my code to run fewer MySQL queries but I realized it wasn’t enough.
Therefore, I set up my new computer at home (which I bought from PayPal donations, props to the donors!) as a web server. The domain was easily pointed from the web space at Binero.se to my local machine in my living room. A day of tweaking later it worked quite well. The only thing that was a bit strange was the server speed. I looked at the server stats and saw that the memory usage was about 100%, so I bought some more memory. The machine have 12Gb of memory now, which is much for a home PC.
To make the computer actually use the extra memory, I had to tweak some parameters in the MySQL and Apache2 server setting files.
For Mysql, I increased the values of these parameters in /etc/mysql/my.cnf:
Yes, I can now edit the “max_connections” value, which is a great freedom to have. For Apache2, I increased the values for these parameters in /etc/apache2/apache2.conf:
This made the server accept more connections per second, and therefore it has to use a larger portion of the server memory. I increased these values a bit, checked the error logs in /var/log/apache2/error.log to see if the MaxConnections limit was exceeded, and repeated. At the moment the server uses about half of the memory, so I should be able to increase these values a bit more in the future.
The server runs very fast. So fast that I got several comments on it:
I can’t believe how FAST the site is again. Congratulations to Stefan, you seem to be a magician!
Website is working much faster today! more memory must have been added!
One good thing that all this mess brought was that my blog got some more hits. I guess the users Googled for “friendship-bracelets.net” when they couldn’t connect to it, and of course they got my blog up in the top results. Below you can see the number of visitors to Steffe.se during the same time period as the graph earlier. Note its shape and compare it to the other graph.
Thanks to all patient and supportive users. Love ya.