Amazon S3 vs EC2 – Differences and Similarities (with Case Studies)

Amazon Web Services, or AWS, is the biggest cloud platform among cloud services. It powers numerous digital infrastructures of private and public organizations of all different sizes. When AWS was first launched in 2006, it …

amazon-ec2-vs-s3

Amazon Web Services, or AWS, is the biggest cloud platform among cloud services. It powers numerous digital infrastructures of private and public organizations of all different sizes. When AWS was first launched in 2006, it started with a few core services. Two of them were EC2 and S3. These first-generation services have been cornerstones of AWS, and fifteen years later today, people still actively use these two services. In this article, we will find out what S3 and EC2 are and their differences and similarities.

EC2

EC2 stands for Amazon Elastic Compute Cloud. EC2 was one of the first generation services in AWS. EC2 is basically a server running on the cloud. Traditionally, to run your system on a server, you had to buy servers and install them on-premise. They were unimaginably demanding tasks from ordering to maintaining those infrastructures by yourself. It was expensive and inefficient. When they get old, you will have to replace them and migrate all your software into new ones.

When EC2 came along, it changed the game. I still remember my first experience with EC2. With only a few clicks, I could have servers at an extremely low price. Whole industries benefited from this new way of having servers. What’s more amazing is upgrading EC2 hardware, for example, higher CPU, RAM, or bigger storage, you can also do it with a few clicks without having to worry about migrating your software. When you upgrade, AWS automatically moves all your software into new ones. This makes vertical scaling so easy. In addition, you can mount storage (EBS or Elastic Block Storage) of various sizes to different Amazon EC2 instances flexibly.

S3

S3, or Simple Storage Service, is an object storage service. This is the storage infrastructure that Amazon.com uses for its global e-commerce network. You can use the service to store all types of files (like your local hard drive) in any size at an affordable price. You may consider it as being similar to cloud file storage services like Google Drive, Dropbox, or Box. Well, it is partly similar in the way that you can store files on the cloud. But, it is more than just storing files.

In addition to file storage, Amazon Simple Storage Service provides additional features that allow users to build Internet applications, perform file backup and recovery. You can also use S3 as storage for data lakes for big data workloads and analytics and hybrid cloud storage. The service is known for scalability, high availability, and low latency with 99.999999999% durability and between 99.95% to 99.99% availability according to Wikipedia. This reliability is critical for business continuity.

S3 and EC2 are separate services so they have many more differences than similarities. However, there are still certain aspects that they commonly share.

Similarities

The similarities exist across functional and architectural areas. However, S3 and EC2 were designed with different goals. Thus, the best use cases for both should be different. It will be difficult and not desirable to use one to replace another.

Front-end Code Repository for Application

An EC2 instance is a server. In EC2, you can store code and miscellaneous files such as images, videos, audios, and more to be used for your application. You can also put back-end and front-end codes to run it. There is no surprise here.

From the explanation about S3, we learned that S3 is storage. We know that we can store those files. What’s interesting here is that you can actually store front-end codes like HTML, Javascript, ReactJS, and more for your application. Of course, you can store contents files such as videos, audio, and images in S3 so that your application can also use them. To use S3 as a front-end source, we need an architectural shift from being server-based to be serverless.

In AWS, it provides a serverless ecosystem with Lambda. AWS Lambda is basically a function that can be called from various points including EC2, API Gateway, CloudWatch, and many more. When you adopt a serverless concept, you put your back-end codes in Lambda and front-end in S3. We will cover this in detail in the use cases section below. For the similarity point here, keep in mind that you can use S3 for front-end codes. When you plan to build a static website, this architecture can help you to reduce cost dramatically.

File Storage

When you use S3 on the AWS web console, you might forget that S3 fundamentally runs also on servers. AWS provides a convenient UI-based management console where users can upload and download files and use other extensible features. But, S3 is basically servers like EC2. You can store filed both in S3 and EC2. If we want to argue the best use cases, AWS generally would recommend users to use S3 to store files. In terms of functionality, you can use both to put your files.

S3 provides almost unlimited storage size and, with EC2, you can increase storage size and add the number of EC2 instances for even more storage. Again, AWS wouldn’t recommend you to scale up EC2 just for storage size. For file management, S3 offers much more powerful options and affordable pricing structures. Plus, it provides easy data backup.

Compatible with Other AWS Services

In AWS, there is no service that’s completely isolated. All AWS services can interact with other AWS services. EC2 and S3 are no exception. They can be called by other services and vice versa. EC2 can access S3 to use and manage files. AWS has extensive API libraries in all major programming languages. Users can use them to programmatically interact with the resources in AWS.

Differences

Because they are different services, there are more differences than similarities. The dissimilarities come from the purpose of EC2 and S3.

Server vs. Storage

Although you can find a few functional similarities as shared above, each of them was designed with a different goal. EC2 is a server service. It has become one of the most important trademark services of AWS. EC2 is also used in other AWS services where there need to be servers. For example, when you train a machine learning model, it requires high computing power. In AWS SageMaker, when you execute a training job, SageMaker lets you choose the number of instances and type so that you can freely use EC2 instances for training.

Redshift is AWS’ data warehouse service that runs on servers. You can horizontally scale up and down by deciding the number of instances and their specifications. There are many more use cases that explain the purpose of EC2.

S3 is a storage service in AWS. But, there are more. Just as EC2 instances are used by other AWS services, S3 is also used when there needs to be storage. For example, S3 is used to build a data lake in AWS. Thanks to the characteristics of file storage, you can store structured, semi-structured, and unstructured data in Amazon S3 buckets. This is in contrast to relational databases where you can only store structured data. Then, you can query those data using AWS Athena. S3 can be used to store code files to be run in other services. S3 is an extensible storage service in AWS.

Pricing Structures

Another main difference is their pricing structures. For EC2, AWS charges you based on the number of hours your EC2 instances are running. For S3, you are charged by the total data size in your S3 bucket. The cost can be further differentiated by the type of your EC2 instance. As you use a more powerful EC2 instance and attach larger storage, it becomes more expensive. In S3, you can achieve cost savings by using different storage types such as IA (Infrequent Access) or Glacier.

Cloud cloud cloud… Source

Case Studies

A good way to understand EC2 and S3 is by looking at examples. Here, we will have a look at five use cases for EC2 and S3 across diverse industries. As you read through, you may be able to get a good idea on how you want to use the services.

Edmodo

Edmoto is a global online education tech company that experienced 1,500 percent jump in the users during the COVID-19 pandemic period. To meet the surge in demand, Edmoto had to scale swiftly. Edmoto was using EC2 and CloudFront. Patchin, vice president of marketing for Edmodo, said, “Using Amazon EC2 instances, we’ve been able to quickly increase site capacity by 15 times to continue to provide teachers and students with uninterrupted access to our solutions for their distance learning needs.” Since EC2 instances can be easily scaled up vertically and horizontally, Edmodo was able to catch up with the growing demand.

INEOS TEAM UK

INEOS TEAM UK is a British sailing team based in Portsmouth, England. The team was formed in 2018 with the aim of bringing the America’s Cup – the oldest international sporting trophy in the world to the U.K. The upcoming race will be held in Auckland, New Zealand in 2021. Like all the other teams, the team will compete in a boat that’s designed by the team. There are guidelines set by race organizers to test the crew’s sailing skills. Part of the aim of the restrictive rules is to control the cost of joining the race so that many entrants can compete.

In spite of the restrictions, teams can still design the shape of the boat’s monohull and foils. However, it is not possible to physically create various designs and test on the water. To resolve the issue, engineers turn to computer-based simulations to optimize their designs. Testing goes through thousands of simulations to find the best boat shapes and positions on the ocean. INEOS TEAM US needed to run 2,000 – 3,000 simulations for their boat.

To achieve both speed and cost-effectiveness, the team chose AWS EC2 instances and used spot instances, which let users access unused Amazon EC2 capacity at a lower price. “The speed combined with the low cost of the Amazon EC2 Spot Instances means we can do many thousands more simulations within our design budget,” says Holroyd, the Head of Design. He added, “One question I constantly ask myself is whether we’re spending our money wisely. Using AWS, I have no doubts because it massively compresses the computational turnaround, maximizing design time.”

BandLab

BandLab is a music cloud company that helps users compose, mix, revise, sync, and collaborate through digital devices – smartphones, tablets, and computers. Since people can use these everyday digital tools, they can enjoy great accessibility and convenience to make music. BandLab app attracts more than 40,000 new users every day globally. With the continuous growth, BandLab had to find a place to store 4PB of data and to prepare additional storage for the future. To meet the demand for the massive amount of data, BandLab chose AWS S3.

Nick den Engelsman, Senior Cloud Systems Engineer and Architect, said, “We made the decision in early 2017 that any audio-related stuff—transcoding, mixing, you name it—would be done on AWS.” He added “The main reason we wanted to move was because we expected the number of users would scale in the future, and as a result, so would the number of audio samples that users would upload and that we’d have to transcode. We knew that Amazon S3 would be able to handle it, as it has virtually unlimited scale.” By using AWS S3, the firm was able to serve 26 million users by the end of 2020 with optimized costs.

Asianet News Media & Entertainment

Asianet News was running its applications – content management systems, news web applications, and mobile app, with Amazon Relational Database (RDS) and EC2. The media firm experienced thousands of concurrent users per second and unforeseeable traffic spikes. The use of their RDS was read-centered than writes, which made the firm pay higher infrastructure costs during peak periods. Anoop Mohan, product manager of Asianet News, explains that, with EC2’s hourly pricing, they still had to pay for the low or idle EC2 instances during low traffic periods.

To optimize the use of data and server infrastructure and their cost, they decided to move from RDS to DynamoDB and to Lambda instead of EC2. The company achieved low-latency performance from the backend by integrating Lambda with API Gateway, DynamoDB, S3, and CloudWatch. Mohan said, “Thanks to Lambda’s subsecond metering model, we pay only for what we consume in milliseconds instead of hourly and we cut the overall operating costs by 50%. The switch to DynamoDB also empowered us to easily synchronize and operate multiple events in parallel with Lambda, helping us to further slash database costs by 48x.”

MilesWeb

MilesWeb builds, hosts, and manages websites for enterprises around the globe. The firm offers services for various types of websites including blogs, personal websites, and e-commerce websites. The company provides 24/7 technical assistance to over 10,000 customers. MilesWeb was launched in 2012. Since then, it bought or leased on-premises servers and data centers to run its customer websites. Chinmay Dingore, co-founder and executive director of MilesWeb, says, “One of the challenges we faced was downtime, which once added up to 12 to 16 hours over a period of six months. This level of interruption was unacceptable to our customers with high-traffic, e-commerce websites.”

Other big challenges included long time processes to attach additional storage or upgrade RAM, which led to downtime. After they migrated their infrastructure to AWS, they experienced high performance and low cost. Their website latency went down by 30 percent and management cost fell by 30%. Chinmay Dingore, co-founder and executive director of MilesWeb, said, “It took 5 to 6 seconds for a website to load, but, since moving to AWS, load times have been cut to 3.5 to 4 seconds—a reduction of around 30 percent.” He added, “We’ve reduced our management costs by 30 percent from the migration.”

To increase storage size in EC2 instances, you can use Amazon Elastic Block Store. You can attach EBS volumes into the server instances so that you can have scalable file storage in the cloud infrastructure.

Wrapping up

In this article, we learned the similarities and differences between S3 and EC2. Those two AWS services play a critical role in the AWS ecosystem and they exist to empower each other. As you read the case studies, you would now have a better understanding of the two services and AWS in general. The good news is that AWS offers free trials and there is no better way to learn something than getting your hands dirty.