Serverless on ARM: Running AWS Lambda on Graviton2

Serverless on ARM: Running AWS Lambda on Graviton2

Nov 21st 21ARMAWSLambdaGraviton2

Introduction

Processor's Micro-architectures are the backbone of Computer Science and Engineering. These architectures represent how logical instructions are implemented for a given CPU/GPU. The overall design of a micro-architecture, coupled with the manufacturing process (MOFSET Technology Node) are the two principal factors that determine the performance and power-efficiency of a given chip.

Today, the most used architectures are x86 and ARM. The x86 architecture was officially introduced by Intel in July 1979 with the launch of the 8080 processor, which was one of the first attempts to design a general-purpose CPU, instead of custom designed chips for each client. Later on, x86 evolved from 16bits to 32bits and then 64bits (also known as x86-64 or just x64) to become the most used architecture in the world.

On the other hand, the first version of the ARM architecture was introduced by Acron in 1985. The name ARM originally stood for Acron RISC Machines before it changed to Advanced RISC Machines. The first design was an attempt to make a simple and efficient architecture compared to the existing x86, by using a limited instruction set and focusing on minimizing power consumption. The final design made an important impact in the silicon industry, since it offered close to x86-32bit performance with a huge reduction in the production cost as well as power consumption. This led to a mass adoption of the architecture especially in mobile devices, and by the year 2005, 98% of all produced mobile phones used at least one ARM chip.

Today, ARM processors are not only omnipresent in our daily life, but also adopted by Industry Leaders, such as Cloud Providers who started adding ARM instances to their portfolio. This type of instances promise close to x86 performance at a lower price point. AWS is one of the most important players in the Cloud Industry who offer ARM instances. These servers run on in-house designed chips called Graviton. The first version of Graviton (Graviton1) was introduced by Peter DeSantis during Amazon's AWS re:invent 2018. This version took a form of a 16-core ARMv8 (Cortex-A72) SOC running at up to 2.3Ghz, and even though it offered a greate performance / price, it didn't quite match the x86 peak performance. The second iteration (Graviton2) launched in 2020 and offered a more powerful SOC featuring a 64-core ARMv8, clocked at up to 2.5Ghz.

Since its launch, Graviton2 was offered only in EC2 instances, until the 29th of September of this year. During the AWS re:invent 2021, AWS officially announced that Lambda Functions can also now be ran on Graviton2 and take advantage of it's higher price to performance ratio.

In this article, we will run Serverless Lambda Functions on the new architecture. We will test different use cases and workloads and analyze its performance and the cost compared to x86.

Evaluation Workloads

AWS Lambda is used for a variety of different cases across industries, from media processing and file uploads to REST APIs and Data Analytics.

In our test, we will focus on processing high resolution media files (pictures and videos) which is a common use for Lambda, for example, some companies build such services to compress pictures and make multiple resolutions for different client devices. The same is also valid for video files, where Lambda can be used to encode an original high resolution file into multiple lower resolutions to serve each client the appropriate resolution based on the device and his bandwidth.

For pictures processing, we will implements the following operations:

  • Picture resize: Downscaling and upscaling the picture to different resolutions than the original one, while keeping the same aspect ratio. For example, upscaling a picture from a resolution of 1000x500 to 2000x1000.
  • Crop: Selecting and returning a specific area of a picture based on requested coordinates. For example, selecting the rectangular area between x1(100,300) and x2(550,700) from a picture of a resolution on 1000x1000.
  • Image Rotation: We will rotate the picture counter clock-wise by a certain degree.
  • Image enhancing: Change the format of pictures from one to another, for example from JPEG to PNG.

For video processing, we will make the following functions:

  • Video encoding: Which consists of taking a raw video file and encoding it in the x264 and x265 codecs. We will be using ffmpeg for the task and we will test a variety of bitrates and encoding presets.
  • Resizing videos: This will consist of upscaling and downscaling the video to different resolutions.

Evaluation Implementation

The Serverless Architecture

For both the image and video processing functions, we used SAM for writing and deploying the serverless architecture. We also used Lambda Layers to automate ffmpeg's and Pillow's binary injection for each function. The binaries were uploaded to S3 and then ARN referenced in the SAM YAML deployment file. The architecture looks like the following.

Made with a lot of

and