Posts Tagged: AWS

AWS lowers cloud pricing by launching the T2 instance type that can burst to handle occasional workload spikes

Amazon Web Services cloud platform logo

T2 instances are Burstable Performance Instances that provide a baseline level of CPU performance with the ability to burst above the baseline. The baseline performance and ability to burst are governed by CPU Credits. Each T2 instance receives CPU Credits continuously at a set rate depending on the instance size.  T2 instances accrue CPU Credits when they are idle, and use CPU credits when they are active.  T2 instances are a good choice for workloads that don’t use the full CPU often or consistently, but occasionally need to burst (e.g., web servers, developer environments, and small databases).

Continue reading

Powerful Redmine in AWS

In this post I will show how to install Redmine on AWS using several useful AWS services (EC2, RDS, S3, SES, ElastiCache) and make it auto-scalable.

Historical Note (2014): This walkthrough originally targeted Ubuntu 14.04 LTS (PV), Ruby 2.x, and Redmine 2.5. Inline corrections below fix command typos, YAML indentation, Apache XML tags, and insecure defaults for anyone referencing the architecture today.

Redmine

Continue reading

Amazon SES: Simple Email Service

Amazon Simple Email Service (Amazon SES) is a highly scalable and cost-effective bulk and transactional email-sending service for businesses and developers. Sign-up is quick and on a pay-as-you-go basis. Amazon SES

Continue reading

Delete an Elastic Beanstalk bucket

If you can’t delete an Elastic Beanstalk-created bucket, first remove all files inside the bucket, then remove the bucket policy.

Go to the bucket’s policy (Bucket -> Properties -> Permissions -> Edit bucket policy).

Save the changes to the bucket policy.

Now right-click on the bucket and press Delete.

AWS t1.micro 100% CPU

Sometimes EC2 CloudWatch monitoring shows 100% CPU usage, but when you SSH into your instance and check it with ‘top’, it’s hard to tell what is happening. Amazon is probably “borrowing” some of your CPU cycles to give to someone else who needs them. This is standard practice in a virtualized environment where physical server resources like RAM and CPU cycles are often heavily overcommitted.

slowTo check for CPU steal, run top and look at the %st value. If this value is anything other than zero, your VM’s CPU cycles are being “borrowed”.

To watch per-core steal time continuously over 1-second intervals, you can also run:

mpstat -P ALL 1

Modern Note: Legacy t1.micro shared baseline CPU aggressively when noisy neighbors spiked. Modern Nitro-based T3/T4g instances (and Dedicated hosts) isolate vCPUs much more predictably as long as CPU credits stay positive.

Recovering a Lost Amazon EC2 SSH Key

amazon-ec2If you lose your Amazon EC2 SSH key and can’t log in to your instance, this isn’t a big problem as long as your instance is EBS-based and uses an Elastic IP.

1. Upload your new SSH key, or use one generated by AWS.

2. Create an AMI of your instance.

3. Launch a new instance from your AMI and select the new SSH key.

4. Log in to your instance with the default user (ubuntu or ec2-user, depending on your original AMI).

5. Reassign the Elastic IP to the new instance.

6. Turn off the old instance and terminate it.

Modern Alternatives (No Instance Replacement Required): Today you can usually regain access without cloning an AMI by connecting via AWS Systems Manager Session Manager, pushing a temporary key through EC2 Instance Connect, or stopping the instance to attach its root EBS volume to a temporary rescue VM and updating ~/.ssh/authorized_keys directly.

RDS Instance Sizes, maximum concurrent connections

Historical default max_connections limits across first-generation Amazon RDS MySQL instance classes:

RDS Instance ClassDefault max_connections
db.t1.micro34
db.m1.small125
db.m1.medium296
db.m1.large623
db.m1.xlarge1,263
db.m2.xlarge1,441
db.m2.2xlarge2,900
db.m2.4xlarge5,816

In RDS Parameter Groups, the dynamic formula defaults to {DBInstanceClassMemory/12582880} for MySQL and LEAST({DBInstanceClassMemory/9531392}, 5000) for PostgreSQL. On modern instance families (such as db.t3 and Graviton db.t4g), pooling connections with Amazon RDS Proxy prevents connection exhaustion from serverless or autoscaling workloads.

Amazon Relational Database Service (RDS) database icon

How to waste less money with AWS

First of all, you need to carefully select the region where you are going to establish your servers.

US-EAST / US-WEST-2 were the cheapest regions at the time I wrote this.

You can check the prices per region in the links at the end of this post.

Amazon Web Services cloud platform logo

While using AWS for almost a year on the Free Tier, I didn’t pay attention to instance purchasing options.

Choosing the right AWS region alongside Reserved capacity, Savings Plans, Spot Instances for fault-tolerant jobs, and ARM64 AWS Graviton instance families can cut monthly compute bills significantly without sacrificing reliability.

Pricing references: Amazon EC2 Pricing | EC2 Purchasing Options

How to survive with an AWS EC2 t1.micro instance

amazon-ec2

With my t1.micro, I can host my personal Redmine, Git, and blog, which I couldn’t do with the default settings.

I used a swap file for it, and here is how you can set it up:

Copy & paste the code below:

sudo dd if=/dev/zero of=/var/swapfile bs=1M count=2048 status=progress
sudo chown root:root /var/swapfile
sudo chmod 0600 /var/swapfile
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
echo '/var/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

To disable it cleanly later, run:

sudo swapoff -v /var/swapfile
sudo rm /var/swapfile
sudo sed -i '\|/var/swapfile|d' /etc/fstab

Alongside swap, keeping a tiny VM responsive came down to caching and restraint: placing Varnish in front of Apache absorbed static/anonymous reads before spawning memory-heavy worker processes, while PHP bytecode caching (APC back then, replaced natively by PHP OPcache today) avoided recompiling scripts on every request.

Cloud & Modern Linux Caveats: Heavy swapping on network-attached EBS volumes adds latency and burns through storage IOPS burst credits, so keep vm.swappiness=10 and treat swap strictly as an OOM safety net. On modern Linux kernels, compressed in-memory swap with zram is much faster and avoids unnecessary disk writes, while older tools like prelink are deprecated because of ASLR.

Amazon Web Services: Free Tier

Amazon Web Services cloud platform logo

How do you get started with AWS for free?
Just go to https://aws.amazon.com/free/ and create your account.
A credit card is required, even for a free account.

Historical Context (2013): When this article was written, AWS Free Tier offered t1.micro instances with 613 MB of RAM. Modern AWS Free Tier accounts provide t2.micro / t3.micro instances (1 GB RAM) for 12 months plus selected Always Free allowances (such as DynamoDB and AWS Lambda).

What can you do with the free account?
It’s up to you! If you are building a light-traffic website, the Free Tier can handle it. 🙂

You can have up to two EC2 instances (1 Linux, 1 Windows) with 613 MB of RAM and up to 30 GB of EBS storage. You can use all 30 GB on a Linux instance, which is the best way to spend your “free” resources (Windows is memory-hungry).

You can have up to one RDS instance (PostgreSQL, MySQL, …) with 20 GB of database storage and 20 GB for backups.

You can use Amazon S3 with up to 5 GB of storage and up to 20k PUT and 20k GET requests.

You can have up to one Memcached node with 213 MB of RAM.

And a few other services (ELB, DynamoDB, SNS, CloudWatch, …).

Continue reading