Reading Time: 6 minutes
I performed upgrade from 3.5 USD plan of LightSail to 5 USD plan.
– At 11 p.m. 07/23/2021
Recently I have complaint about below stuff.
- Slow response when using Visual Studio Code Remote Development - Timeout occurrs when accessing blog page - Database conectivity error happens when uploading image file
I investigated and found RAM is near empty.
So I did upgrade to 5 USD plan.
– RAM: 512MB -> 1GB
This article shows background and how I did upgrading.
Please go to this section if you want to know only how to do it.
As mentioned previous section I sometimes face database connectivity error like below.
Error establishing a database connection
I also face slow or no response from blog page…
This is when blog page is frozen… PV is much lower than usual.
I decided to solve to prevent bad effect to blog page.
I came up to doubt mysql because my blog page uses mysql and error message is related to database.
But mysqld is alive.
– Port 3306 which is used by mysql is occupied.
– “Minimum Available is xxxMB is output by free -h.
I took screenshot again after querying blog page some times.
MemAvailable looks 56MB which is much lower than above.
If you are geek of Linux, you know oom killer which kills process randomly when available memory is going to run out.
According to my experience of my job,
oom killer is likely to start if free memory is less than 5% of whole memory.
Current LightSail is 512MB, so about 27MB is threshold.
“MemAvailable 56MB” means I have only 30MB buffer.
In case of this screenshot I didn’t connect by Visual Studio Code.
This means if I use Visual Studio Code Remote Development, oom killer may run.
– I referred this site which is Japanese geek.
To avoid oom killer I have option not to use Visual Studio Code Remote Development and use vim or other lightweight text editor.
But I am not specialist of vim and familiar with Visual Studio so I feel like using Visual Studio…
I decided to increase free memory to solve this problem with using Visual Studio Code.
In my case below processes use much memory.
httpd: 80MB max php-fpm: 150MB max mysqld: 80MB max
I referred configuration of php-fpm/PHP focusing on memory usage.
This is php-fpm configuration.
sudo cat /opt/bitnami/php/etc/php-fpm.conf (snip) pm=ondemand pm.max_children=5
This is PHP.
sudo cat /opt/bitnami/php/etc/php.ini (snip) memory_limit = 512M
I configured to investigate I can increase free memory but it didn’t.
How to upgrade LightSail instance
Below steps to upgrade.
Stop current instance Take snapshot of current instance Detach static IP address from current instance Create instance of 5 USD from snapshot Attach static IP address to 5 USD instance Smoke test
Duration time was about 30 mins.
I would recommend to perform at time frame when access is low.
– Ex: midnight
Stop current instance
Stop instance at the page management of instance.
Wait to be able to see Stopped.
Take snapshot of current instance
Choose Manage on Instance page.
Choose Snapshots tab.
Choose Create snapshot.
If snapshot name is OK, click Create.
Now it will start snapshoting.
You can confirm snapshort is successfully created.
It takes more time than expected.
In my case it took about 10 mins.
Detach static IP address from current instance
Go to instance management page,
Go to Networking and select Detach.
You will see warning, but select Yes, detach.
Static IP address is detached and is not available by any instance.
Create instance of 5 USD from snapshot
Click︙ on the right side of snapshot and choose Create new instance.
I selected $5 to increase 1GB of RAM.
You can edit the name of instance as you like, then choose Create instance.
New instance has been created.
It takes about 1 mins.
New instance looks supporting IPv6.
Attach static IP address to 5 USD instance
We need to attach static IP address which we detached from old instance.
Go to Networking and choose Attach static IP.
Select static IP address which you detached just before.
– In case of this image, Staticip-3.
Now you can see this static IP address is attached to new instance!
To make sure I restarted instance to reflect this attachment.
Let’s do smoke test.( ´ー｀)y-~~
SSH from browser is Okay.
This is output of htop.
Mem is about 1GB as expected.
– I don’t know why used memory is already over 512MB???
Disk space is also increased from 20GB to 40GB.
The count of CPU is 1 because $5 instance has only 1 as well as $3.5.
I could access this blog page.
I saw warning message from JuiceSSH like
Public key is changed, is it OK?
It is expected behavior, then we can accept.
– Sorry I took only Japanese screen shot.
We can see similar error when using ssh command.
As mentioned in above error message please do this command.
ssh-keygen -f <path to known_hosts> -R <host name or IP address>
Let’s do ssh command, then you should be able to login after yes.
I keep old instance just in case.
I intend to delete old instance after 1 month if no trouble.
How was it?
It takes a bit much time than expected, but upgrading has no command line to be executed, so we don’t need to worry about any mistake!