{"id":6747,"date":"2022-04-02T16:10:01","date_gmt":"2022-04-02T07:10:01","guid":{"rendered":"https:\/\/the-world-star.com\/?p=6747"},"modified":"2026-11-21T12:37:39","modified_gmt":"2026-11-21T03:37:39","slug":"investigating-and-resolving-aws-ec2-freezing-issues-troubleshooting-low-memory","status":"publish","type":"post","link":"https:\/\/the-world-star.com\/en\/server\/investigating-and-resolving-aws-ec2-freezing-issues-troubleshooting-low-memory-6747\/","title":{"rendered":"Investigating and Resolving AWS EC2 Freezing Issues: Troubleshooting Low Memory"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">My EC2 instance occasionally starts hanging. 2022\/03\/31<br>This started happening after setting up the WordPress environment. I was careful about storage capacity during installation and everything seemed fine. This is a memo of the investigation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Investigation 1<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It happens about once every 1 to 2 days, always sometime in the middle of the night. AWS monitoring shows that CPU utilization spikes to 100%, followed by a status check failure, and every 30 minutes, network access for backups drops off. SSH login also becomes impossible. (\u203b When it happened the first time, it was barely clinging to life and SSH was extremely sluggish.)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Checking EC2 Monitoring Logs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">CPU utilization pins at 100%, after which CPU credits are exhausted, bringing CPU utilization down to 0%, and the system hangs completely. While there were still CPU credits left, SSH was probably just barely working.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">According to AWS EC2 monitoring, CPU utilization started climbing on 3\/31 at 3:35, staying at 100% from 3:40 to 4:00.<br>At 4:10, CPU credits hit 0, and CPU utilization dropped to 0.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/static.the-world-star.com\/wp-content\/uploads\/2022\/05\/20220331Hung.png\" alt=\"\" class=\"wp-image-38\" width=\"650\" height=\"413\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Linux System Log Investigation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">There are suspicious records in the system logs.<br>I checked the system log at \/var\/log\/syslog. There are logs showing the OS hanging and dumping.<br>This is my first time analyzing a Linux hang, but it&#039;s pretty interesting.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2014-Is this where the kernel starts screaming?\u2014\u2014<br>Mar 31 04:06:49 ip-172-31-45-138 systemd-networkd[402]: eth0: Could not set DHCPv4 address: Connection timed out<br>Mar 31 04:08:24 ip-172-31-45-138 systemd-networkd[402]: eth0: Failed<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Wait, the Ethernet interface is dead?!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2013From here on, the kernel is screaming and dumping logs\u2014\u2013<br>Mar 31 04:09:30 ip-172-31-45-138 kernel: [101314.179745] systemd invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0<br>Mar 31 04:09:31 ip-172-31-45-138 kernel: [101314.179754] CPU: 0 PID: 1 Comm: systemd Not tainted 5.13.0-1019-aws #21~20.04.1-UbuntuMar 31 04:09:31 ip-172-31-45-138 kernel: [101314.179757] Hardware name: Xen HVM domU, BIOS 4.11.amazon 08\/24\/2006systemd invoked oom-killer:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What is the oom-killer?! Looking it up, oom stands for Out Of Memory, and it seems to be a log where [systemd] selected and killed a process to prevent out-of-memory conditions. This is likely a log of the system trying to recover after something went rogue and consumed infinite CPU and memory. The process that got killed was the Minecraft server; looking at the oom-killer process logs, it definitely seems to have been eating up the most memory. Let&#039;s check right around that time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Most things running periodically seem to be executed via cron.<br>\u30fbMinecraft backup \u2192 Done intentionally<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Mar 31 03:30:01 ip-172-31-45-138 CRON[15399]: (ubuntu) CMD (\/home\/ubuntu\/MinecraftServerBedrock\/worlds\/mc_backup_hourly_YuikaAndB.sh)<br>Mar 31 03:30:31 ip-172-31-45-138 CRON[15398]: (CRON) info (No MTA installed, discarding output)<br>\u30fb(CRON) info (No MTA installed, discarding output)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2192 This log appears when mail settings are not configured. If configured, it apparently emails error details.<br>Could something in the backup script be throwing an error? Since it also appears before the hang occurs, it doesn&#039;t seem to be related to the hang.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30fbNext is php&#039;s phpsessionclean.service: Succeeded. \u2192 Is this cleaning up PHP installed for WordPress? PHP-related things are suspicious because the installation froze halfway, but the logs show it succeeding.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30fbNext is apt updates, daily updates perhaps?<br>Mar 31 03:39:23 ip-172-31-45-138 systemd[1]: Starting Daily apt download activities\u2026<br>\u3000\u3000\uff1a<br>Mar 31 03:39:28 ip-172-31-45-138 systemd[1]: Started PackageKit Daemon.<br>Mar 31 03:44:56 ip-172-31-45-138 PackageKit: daemon quit<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Mar 31 03:49:18 ip-172-31-45-138 packagekitd[15843]: Error releasing name org.freedesktop.PackageKit: Timeout was reached<br>\u2191 That&#039;s a major error showing up. Could this error have triggered the hang? It looks like a network timeout, but it could be caused by something else. Still, I suspect it straight-up killed the apt processes. Indeed, when installing PHP via apt, it froze midway. Could this be the cause?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Towards the end of the dump,<br>\u2014The Minecraft server is being killed due to insufficient memory.\u2014<br>Mar 31 04:09:31 ip-172-31-45-138 kernel: [101314.180132] Out of memory: Killed process 10850 (bedrock_server) total-vm:1026932kB, anon-rss:376956kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:1016kB oom_score_adj:0<br>Followed by logs of various things being stopped.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After that, cron logs for the Minecraft backup and PHP cleanup appear periodically. It doesn&#039;t seem completely dead.<br>Daily apt updates are also succeeding.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Modifying Settings to Record Cron Logs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u25a0 Configuring rsyslog to record cron logs<br>It felt like the cron Minecraft backup script was throwing errors, but I couldn&#039;t find any cron logs. Ubuntu apparently disables cron logs by default, so I&#039;ll change the settings to record them.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br>$ cd \/etc\/rsyslog.d<br>$ sudo cp -p 50-default.conf 50-default.conf_$(date \u201c+%Y%m%d_%H%M%S\u201d)<br>$ sudo emacs 50-default.conf<br>cron.* \/var\/log\/cron.log # Before editing<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2193<br>cron.* \/var\/log\/cron.log # After editing<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ sudo systemctl restart rsyslog<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Logs are located at \/var\/log\/cron<br>Logs started appearing, but they contain the exact same content as syslog. Useless.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Cause is Out of Memory<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u25a0 systemd invoked oom-killer:<br>What is the OOM Killer?<br>&quot;Have you ever experienced a critical application process suddenly dying on Linux, yet checking the application logs reveals no errors outputted? In such cases, the OOM Killer may have terminated the process due to system memory exhaustion.&quot;<br>There is no doubt that running out of memory due to some factor is what&#039;s breaking things.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u25a0 Checking memory usage with the top command<br>Since it&#039;s a memory shortage, I want to check which processes are consuming memory. You can see this with the top command. Top displays process information updated in real-time. It looks like you can sort using the following shortcuts. This is definitely worth taking a note of.<br>\u30fbshift+m: Sort by memory usage<br>\u30fbshift+p: Sort by CPU usage (default)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u25a0 Checking memory usage with the ps command<br>It turns out you can also sort using the classic ps command.<br>ps aux --sort -%mem |head -n30<br>For -%mem, it seems if you input the column header name from the first line of the ps command, it will sort by that.<br>Copy and paste the output into Excel.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1348\" height=\"345\" src=\"https:\/\/static.the-world-star.com\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-04-08-00-02-48.png\" alt=\"\" class=\"wp-image-37\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><br>Since the unit for RSS during a dump isn&#039;t very clear, I calculated and analyzed the ratio between the dump&#039;s RSS and the top command&#039;s RSS.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>dump-rss topRSS<\/code>&nbsp;Ratio Process Name<br><code>94239 139876 1.484268721 bedrock_server<br>34864 120444 3.454681046 s3fs<br>17076 70996 4.157648161 mysqld<br>12044 apt-check<br>9675 43672 3.626037861 apache2<br>9178 42488 4.391524548 apache2<br>8926 41216 4.490738723 apache2<br>8903 39672 4.444544029 apache2<br>8758 39436 4.42951814 apache2<br>8517 39400 4.498744005 apache2<br>4500 18000 2.113420218 multipathd<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As a result, the Minecraft server normally uses about 140M, which is the highest consumer. During abnormal times, relative to everything else, it feels like it&#039;s consuming an abnormal amount. The next highest is s3fs, the command that mounts AWS S3. It consumes a whopping 120M. Let&#039;s get rid of it.<br><br>\u25a0 When someone logs into the Minecraft server, it takes up about 33% memory.<br>Free memory at startup: 69M = 7%<br>$ free -m<br>total used free shared buff\/cache available<br>Mem: 967 743 69 21 154 60<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u25a0 Is it actually running out of memory?<br>Since the logs show the OOM killer triggering at the end, meaning out-of-memory,<br>It&#039;s possible that when various things run simultaneously in the middle of the night, the system actually runs out of memory.<br>Ubuntu apparently has 0 swap by default. Checking confirms it is indeed 0, so setting up swap might be a quick way to verify if it&#039;s a memory shortage.<br>\u2014\u2014Checking memory, including swap<br>$ free<br><code>total used free shared buff\/cache available<br>Mem: 991160 591828 130884 3344 268448 240460<br>Swap: 0 0 0<\/code><br>\u2026Not swapping.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Countermeasure 1: Try enabling swap.<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u25a0 Try enabling swap.<br>This might be a temporary fix, but if it stops crashing, then memory was indeed lacking. If it still crashes, then something is running wild and no amount of memory will help. At that point, I&#039;ll rebuild the server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What should the swap size be?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">According to Red Hat documentation:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Physical Memory Amount and Swap Size<br>Physical memory 2GB or less: About 2 to 3 times the memory<br>2-8GB: About equal to 2 times the memory<br>8-64GB: About 1.5 times the memory<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This sizing is apparently meant to hibernate and back up all memory to disk when sleeping. Nowadays, with massive amounts of memory, dedicating e.g. 64GB of storage just to dump 64GB of RAM takes way too long and is pointless. With memory being plentiful nowadays, is it normal not to swap or sleep at all?<br>Since it&#039;s a server, there&#039;s no need to hibernate as before, but maybe that&#039;s a different setting?<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">My EC2 Swap Size<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Memory size: 1GB<br>Remaining storage capacity: 3GB\/8GB<br>Since I also want to keep storage usage to a minimum, I&#039;ll set the swap size to 1GB.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Execution<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The Amazon documentation explains the procedure thoroughly.<br>https:\/\/aws.amazon.com\/premiumsupport\/knowledge-center\/ec2-memory-swap-file\/<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create a 1GB swap file.<br>1GB = 128MB x 8. I don&#039;t know why the block size is 128M, but I&#039;ll follow the example.<br>$ sudo dd if=\/dev\/zero of=\/swapfile bs=128M count=8<br>8+0 records in<br>8+0 records out<br>1073741824 bytes (1.1 GB, 1.0 GiB) copied, 15.2512 s, 70.4 MB\/s<br>Takes a little bit of time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Update read\/write permissions for the swap file.<br>$ sudo chmod 600 \/swapfile<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. Set up Linux swap space<br>$ sudo mkswap \/swapfile<br>Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)<br>no label, UUID=6c93a3d7-008d-49be-b566-926ac00bc892<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Add the swap file to the swap space so that it can be used immediately.<br>$ sudo swapon \/swapfile<br>Verify that the procedure completed successfully.<br>$ sudo swapon -s<br>Filename Type Size Used Priority<br>\/swapfile file 1048572 2304 -2<br>It&#039;s already swapping.<br>ubuntu@ip-172-31-45-138:~$ free<br>total used free shared buff\/cache available<br>Mem: 991160 609344 80148 21352 301668 202472<br>Swap: 1048572 2304 1046268<br>Edit the \/etc\/fstab file so the swap file enables upon startup.<br>Open the file in an editor.<br>$ sudo emacs \/etc\/fstab<br>Add the following new line to the end of the file, save, and exit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\/swapfile swap swap defaults 0 0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">How is the storage capacity?<br>$ df \/<br>Filesystem 1K-blocks Used Available Use% Mounted on<br>\/dev\/root 8065444 6516508 1532552 81% \/<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">81% used, leaving 1.5GB.<br>It&#039;s tight\u2014barely enough to last a year once WordPress is running.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Investigation 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u25a0 Checking hang logs from other days<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3\/31 3:35: Same as described above. Triggered by Daily apt, eth0 dies, oom-killer activates, and bedrock_server is killed. snapd throws a SIGABRT afterwards.<br>Around 3\/31 19:00: snapd throws a SIGABRT. Triggered by Daily apt, eth0 dies, oom-killer activates, and bedrock_server is killed.<br>4\/2 5:40: snapd throws a SIGABRT. Triggered by Daily apt, eth0 dies, but oom-killer doesn&#039;t run.<br>Mostly the same pattern.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u25a0 snapd looks suspicious. Can I stop it? How do I stop it?<br>What is snapd?<br>A package management tool similar to apt.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2013Applications installable via snapd<br>Listing frequently used applications:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">certbot<br>mysql<br>postgresql<br>aws-cli<br>Google Cloud SDK<br>heroku<br>VSCode<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Did it get installed when I added MariaDB? \u2192 Probably not.<br>$ snap list<br>Name Version Rev Tracking Publisher Notes<br>amazon-ssm-agent 3.1.715.0 5163 latest\/stable\/\u2026 aws\u2713 classic<br>core18 20220309 2344 latest\/stable canonical\u2713 base<br>core20 20220318 1405 latest\/stable canonical\u2713 base<br>lxd 4.0.9-8e2046b 22753 4.0\/stable\/\u2026 canonical\u2713 \u2013<br>snapd 2.54.4 15177 latest\/stable canonical\u2713 snapd<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Did it install when I added some Amazon tool?<br>Is it included by default?<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u25a0 Countermeasure 2: Stop mounting S3.<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Mounting S3 is consuming more memory than expected.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Install the AWS CLI to manage S3 via CLI commands like mv<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">I used this as a reference. Since I&#039;ve previously configured S3 and its access settings, this is just for installation and authentication setup. https:\/\/qiita.com\/uhooi\/items\/e915873ddabdf6e27fd7<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Modify the Minecraft backup script<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Instead of mounting S3 and doing regular mv operations for Minecraft backups inside a standard directory,<br>I&#039;ll replace them with AWS CLI commands.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><br>\u2014\u2013\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u3053\u3093\u306a\u611f\u3058-<br>S3\u306baws s3 \u30b3\u30de\u30f3\u30c9\u3067\u76f4\u63a5\u30a2\u30c3\u30d7\u3059\u308b\u305f\u3081\u306e\u8a2d\u5b9a<br>BK_TIME=date +%Y%m%d-%H%M00 #aws s3\u3067\u3082\u3053\u308c\u3092\u4f7f\u3046<br>S3_PATH=\u201ds3:\/\/minecraft-xxxx\/worlds_backup\u201d<br>S3_PATH_NAME=\u201d$S3_PATH\/mc_backup_hourly_${BK_TIME}.tar.gz\u201d<br>:<br>:<br>#\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u30c6\u30f3\u30dd\u30e9\u30ea\u304b\u3089\u65e5\u4ed8\u4ed8\u304d\u306e\u540d\u524d\u306b\u3057\u3066\u6240\u5b9a\u306e\u5834\u6240\u306b\u79fb\u52d5\u3059\u308b<br>aws s3 mv $TMP_BK_NAME $S3_PATH_NAME #S3\u3092\u30de\u30a6\u30f3\u30c8\u3059\u308b\u3068\u30e1\u30e2\u30ea\u3092\u98df\u3046\u306e\u3067\u3001\u3084\u3081\u3066\u3001aws cli\u3067S3\u306b\u79fb\u3059\u3002<br>#\u53e4\u3044\u306e\u3092\u6d88\u3059<br>aws s3 rm $S3_PATH\/mc_backup_hourly_date +%Y%m%d-%H%M00 -d \u20181 days ago\u2019.tar.gz<br>\u2014\u2014\u2014-<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Check 1: First, run it directly to verify that the backup file is created in S3. However, since there is no corresponding file from the previous day yet, I can&#039;t verify the deletion of old files.<br>move: .\/backup_worls_tmp.tar.gz to s3:\/\/minecraft-nyanpu\/worlds_backup\/mc_backup_hourly_20220402-174300.tar.gz<br>delete: s3:\/\/minecraft-nyanpu\/worlds_backup\/mc_backup_hourly_20220401-174300*.tar.gz<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ufffcAdd block<br>The messages indicate it went well.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check 2: Cron time arrived, let&#039;s verify if it ran.<br>$ aws s3 ls s3:\/\/minecraft-xxxx\/worlds_backup\/<br>2022-02-03 19:18:16 0<br>2022-04-01 17:00:17 96091068 mc_backup_hourly_20220401-170000.tar.gz<br>2022-04-01 18:00:17 96092421 mc_backup_hourly_20220401-180000.tar.gz<br>2022-04-01 18:30:18 96093334 mc_backup_hourly_20220401-183000.tar.gz<br>2022-04-01 19:00:17 96091126 mc_backup_hourly_20220401-190000.tar.gz<br>2022-04-01 19:30:18 96093343 mc_backup_hourly_20220401-193000.tar.gz<br>2022-04-01 20:00:17 96092129 mc_backup_hourly_20220401-200000.tar.gz<br>2022-04-01 20:30:18 96093290 mc_backup_hourly_20220401-203000.tar.gz<br>2022-04-01 21:00:18 96092316 mc_backup_hourly_20220401-210000.tar.gz<br>2022-04-01 21:30:18 96093032 mc_backup_hourly_20220401-213000.tar.gz<br>2022-04-01 22:00:17 96085400 mc_backup_hourly_20220401-220000.tar.gz<br>2022-04-01 22:30:18 96058526 mc_backup_hourly_20220401-223000.tar.gz<br>2022-04-01 23:00:18 96032978 mc_backup_hourly_20220401-230000.tar.gz<br>2022-04-01 23:30:17 96033248 mc_backup_hourly_20220401-233000.tar.gz<br>2022-04-02 00:00:18 96032998 mc_backup_hourly_20220402-000000.tar.gz<br>2022-04-02 00:30:18 96033463 mc_backup_hourly_20220402-003000.tar.gz<br>2022-04-02 01:00:18 96033570 mc_backup_hourly_20220402-010000.tar.gz<br>2022-04-02 01:30:17 96033759 mc_backup_hourly_20220402-013000.tar.gz<br>2022-04-02 02:00:18 96033309 mc_backup_hourly_20220402-020000.tar.gz<br>2022-04-02 02:30:17 96034411 mc_backup_hourly_20220402-023000.tar.gz<br>2022-04-02 03:00:18 96034247 mc_backup_hourly_20220402-030000.tar.gz<br>2022-04-02 03:30:17 96034380 mc_backup_hourly_20220402-033000.tar.gz<br>2022-04-02 04:00:18 96033521 mc_backup_hourly_20220402-040000.tar.gz<br>2022-04-02 04:30:18 96035310 mc_backup_hourly_20220402-043000.tar.gz<br>2022-04-02 05:00:17 96034982 mc_backup_hourly_20220402-050000.tar.gz<br>2022-04-02 05:30:18 96033875 mc_backup_hourly_20220402-053000.tar.gz<br>2022-04-02 10:30:18 96272026 mc_backup_hourly_20220402-103000.tar.gz<br>2022-04-02 11:00:19 96242165 mc_backup_hourly_20220402-110000.tar.gz<br>2022-04-02 11:30:18 96179239 mc_backup_hourly_20220402-113000.tar.gz<br>2022-04-02 12:00:18 96173663 mc_backup_hourly_20220402-120000.tar.gz<br>2022-04-02 12:30:17 96133847 mc_backup_hourly_20220402-123000.tar.gz<br>2022-04-02 13:00:17 96085045 mc_backup_hourly_20220402-130000.tar.gz<br>2022-04-02 13:30:17 95996627 mc_backup_hourly_20220402-133000.tar.gz<br>2022-04-02 14:00:17 95997197 mc_backup_hourly_20220402-140000.tar.gz<br>2022-04-02 14:30:17 95997985 mc_backup_hourly_20220402-143000.tar.gz<br>2022-04-02 15:00:18 95997064 mc_backup_hourly_20220402-150000.tar.gz<br>2022-04-02 15:30:17 95997585 mc_backup_hourly_20220402-153000.tar.gz<br>2022-04-02 16:00:18 96556800 mc_backup_hourly_20220402-160000.tar.gz<br>2022-04-02 16:30:18 97773735 mc_backup_hourly_20220402-163000.tar.gz<br>2022-04-02 17:02:16 113338868 mc_backup_hourly_20220402-170000.tar.gz<br>2022-04-02 17:30:18 100512558 mc_backup_hourly_20220402-173000.tar.gz<br>2022-04-02 17:43:30 100518902 mc_backup_hourly_20220402-174300.tar.gz<br>2022-04-02 18:00:27 100497901 mc_backup_hourly_20220402-180000.tar.gz<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">New backup created successfully. ~20220402-180000.tar.gz<br>However, instead of deleting the file from one day prior, it wasn&#039;t deleted. ~20220401-180000.tar.gz remains.<br>\u30fbCheck the logs again when executed directly in the shell.<br>delete: s3:\/\/minecraft-nyanpu\/worlds_backup\/mc_backup_hourly_20220401-174300.tar.gz Ah! You can&#039;t use wildcards for S3 file paths like that! I was afraid of time lags if I didn&#039;t use a wildcard. But since I always save with &quot;%H%M00&quot; ensuring 00 seconds, it&#039;s fine. Wait, if that&#039;s the case, the wildcard was just left hanging.<br>Removing the * should fix it.<br>Result: OK.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Unmount S3<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check mount name<br>$ mount<br>:<br>s3fs on \/mnt\/s3 type fuse.s3fs (rw,relatime,user_id=0,group_id=0,allow_other)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ ps aux --sort -%mem |head -n 5<br>USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND<br>ubuntu 1114 11.6 22.6 1013588 224108 pts\/1 Sl+ 10:10 54:15 .\/bedrock_server<br>root 314 0.1 11.8 708240 117356 ? Ssl 10:09 0:48 s3fs minecraft-nyanpu \/mnt\/s3 -o rw,allow_other,use_cache=\/tmp,uid=1000,gid=1000,passwd_file=\/etc\/passwd-s3fs,dev,suid<br>www-data 663 0.0 2.5 201804 25672 ? S 10:09 0:02 \/usr\/sbin\/apache2 -k start<br>www-data 643 0.0 2.5 202664 25412 ? S 10:09 0:02 \/usr\/sbin\/apache2 -k start<br>It was using about 11% = 110MB of memory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">- Actually unmount<br>$ sudo umount \/mnt\/s3<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ ps aux --sort -%mem |head -n 5<br>USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND<br>ubuntu 1114 11.6 22.6 1013588 224108 pts\/1 Sl+ 10:10 54:16 .\/bedrock_server<br>www-data 663 0.0 2.5 201804 25672 ? S 10:09 0:02 \/usr\/sbin\/apache2 -k start<br>www-data 643 0.0 2.5 202664 25412 ? S 10:09 0:02 \/usr\/sbin\/apache2 -k start<br>www-data 641 0.0 2.4 202588 24656 ? S 10:09 0:02 \/usr\/sbin\/apache2 -k start<br>\u2013 s3fs is gone<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2014 Memory before \u2014<br>$ free<br>total used free shared buff\/cache available<br>Mem: 991160 515600 168544 10520 307016 304732<br>Swap: 1048572 407296 641276<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2014 Memory after \u2014-<br>$ free<br>total used free shared buff\/cache available<br>Mem: 991160 402604 227372 10604 361184 417644<br>Swap: 1048572 391680 656892<br>Freed up about 110MB = 11%!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u25a0 Result: OK. It was indeed a memory shortage.<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By adding a 1GB swap space and removing the non-essential S3 mount that was hogging memory, the freezes that used to happen 1-2 times a day have completely stopped. The conclusion is that it was an out-of-memory issue during the WordPress environment setup. The actual trigger was daily apt updates via snapd. This likely completely exhausted the memory, which normally sits around 40% utilization. As another countermeasure, should I stop the memory-hungry snapd? Stopping it might be dangerous since security updates won&#039;t run, right? I&#039;ll evaluate this as we go with future operations. This time it was educational and fun.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My EC2 instance occasionally starts hanging. 2022\/03\/31This started happening after setting up the WordPress environment. I was careful about storage capacity during installation and everything seemed fine. This is a memo of the investigation. Investigation 1 It happens about once every 1 to 2 days, always sometime in the middle of the night. AWS monitoring [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2606,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/175.41.248.22\/?p=35","_lightning_design_setting":{"layout":"default"},"footnotes":""},"categories":[3],"tags":[67,70,961,1304,1305],"class_list":["post-6747","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-server","tag-aws","tag-troubleshooting","tag-hangup","tag-analysis","en-US"],"_links":{"self":[{"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/posts\/6747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/comments?post=6747"}],"version-history":[{"count":1,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/posts\/6747\/revisions"}],"predecessor-version":[{"id":6749,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/posts\/6747\/revisions\/6749"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/media\/2606"}],"wp:attachment":[{"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/media?parent=6747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/categories?post=6747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/tags?post=6747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}