Oct 16 2018

Technical issues

Category: TechnicalIuliana @ 15:07

A few days ago the blog started having hiccups again. And since I’ve lost most of my morning trying out Apache settings and then monitoring it and making sure it stays up. I’ve read the documentation, I’ve consulted stackoverflow and it makes sense why my configurations were wrong, but I cannot understand for the life of me why had the blog been working like this for almost 2 years.

To keep it short, my Apache was configured like this:
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>

<IfModule worker.c>
StartServers 8
MaxClients 256
MinSpareThreads 10
MaxSpareThreads 50
ThreadsPerChild 10
MaxRequestsPerChild 4000
</IfModule>

Not sure if these settings are default, or where have I got them from, but apparently these settings are a little too generous for an AWS micro machine. Because, yes, this is the machine this blog is being hosted on.This means, in case you had doubts: 10 GB HDD and 1 GB or RAM, that MySQL and Apache are fighting over. And apaprently lately Apache is winning.
Anyway, I’ve toned down the following values.
<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 14
MaxClients 14
MaxRequestsPerChild 500
</IfModule>

<IfModule worker.c>
StartServers 5
MaxClients 14
MinSpareThreads 10
MaxSpareThreads 50
ThreadsPerChild 10
MaxRequestsPerChild 500
</IfModule>

And the blog has been up all morning. Let’s hope I’ve fixed it, otherwise, I might be forced to upgrade. And I really do not want to do that. I mean, this blog is just a personal project that allows me to practice typing and expressing my ideas in a way other people (maybe!?) can understand. It does not make money, so I’m reluctant to spend too much on keeping it up.  I’ll get into details in a future post, about the costs, advantages, and disadvantages of hosting a site on a virtual machine.

I don’t have many readers, but to the ones that read me, I am really sorry for the blog being down and please bear with it being a little bit slow until I find a solution.

Tags: , ,


Oct 03 2016

WordPress & MySql…

Category: English posts,TechnicalIuliana @ 23:28

… is a recipe for disaster. Once every few weeks I get this:

Error establishing a database connection.

Today I tried another two tricks:
1. Adding the following configurations to the Apache httpd.conf file.

StartServers 3
MinSpareServers 3
MaxSpareServers 5
MaxRequestWorkers 25
MaxConnectionsPerChild 0

2. Configurating MySQL like this in /etc/my.cnf
[mysqld]
innodb_buffer_pool_size=10M
performance_schema=offM
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Set internal buffers, caches and stacks very low
key_buffer = 16K
max_allowed_packet = 16K
table_cache = 1
sort_buffer_size = 16K
read_buffer_size = 16K
read_rnd_buffer_size = 1K
net_buffer_length = 1K
thread_stack = 16K
# Don't listen on a TCP/IP port at all.
# Will still work provided all access is done via localhost
skip-networking
server-id = 1
# Set the query cache low
query_cache_limit = 1048576
query_cache_size = 1048576
query_cache_type = 1
# Set various memory limits very low, disable memory-hogging extras
[mysqldump]
quick
max_allowed_packet = 16K
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 16K
sort_buffer_size = 16K
[myisamchk]
key_buffer = 16K
sort_buffer_size = 16K
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

I’ll come back here with an update, in case I managed to make the bloody damn thing stop from crashing.

[Update]: Well, the database no longer crashed, but the ec2 instance did. So I had to terminate it and create a new one. And of course I did not remember anything I did to keep it working so I cam back to this post. And I just found out that the innodb_buffer_pool_size property value depends on the machine you are on. If it is too big, the connection pool will require too much memory and if you do not have that memory, Mysql will still crash. So I just switched to the smallest value that I think it could be necessary for my blog to be accessed by my 50 readers per day: 10MB. And aside from this I modified my instance to add some swap. You can find a really useful tutorial here, I used the first option to create the file in the current file system.

 

Tags: , ,