Millions of users use various mobile applications every day, and long gone are the days of apps limited to local devices. Today, we are leveraging various cloud solutions to connect and deliver core functionalities of our apps.
This makes not only local application performance critical for its success, but also the speed at which it can push, process and query data from the cloud part.
Performance is important for multiple reasons, including:
- User experience - Users expect a seamless experience regardless of how the application processes the requests
- SEO and rankings - Search engines and app stores consider speed and reliability key components
- Competitive advantage - The application marketplace is becoming more crowded, and performance is often seen as a key advantage from the user’s perspective
Common bottlenecks
There are four key aspects to consider when discussing the performance of mobile applications with cloud components:
- Network latency
- Load times
- Response times
- Data management
Network latency depends on the distance between the end-user and cloud components. However, the quality of the network infrastructure plays a huge role in this as well. The same applies to load and response times, but additional optimizations can be made at the data management layer.
Solutions
AWS as a leading provider in cloud computing space has multiple offerings that can help you understand and optimize bottlenecks in mobile applications that rely on cloud components.
With 33 regions worldwide and 105 availability zones AWS covers most of the world with its high-quality infrastructure that can be utilized through its cloud services. This list is further expanded with 600+ CloudFront POPs which can bring the data so close to your end users that you no longer need to worry about latency.
There are several services offered by AWS that can help you remediate issues with latency, load and response times and data management, but two are most important - CloudFront and Global Accelerator.
![optimize-mobile-apps-cdn-1.webp](https://assets.ignit.group/optimize_mobile_apps_cdn_1_d0185942ba.webp)
CloudFront
AWS CloudFront is a content delivery network (CDN) service offered by AWS. Its main purpose is to take your static data such as text files, images, videos and other types of media and cache them at the AWS edge locations which are close to your end users. This approach severely reduces the latency at which data is delivered to your users which increases load and response times.
CloudFront can also run some small processing at the edge by intercepting pre-defined requests and processing them before they even reach your application.
While reducing the overall load of the application, CloudFront’s greatest strength lies in the increased user experience because the app will load faster and perform better. These performance gains are further increased by utilizing other services that CloudFront natively integrates with such as Global Accelerator.
CloudFront configuration
CloudFront's success is usually measured by a cache hit ratio (CHR). This number is defined as the ratio of requests served by the CloudFront cache versus the total number of requests. A good CHR should be around 0.8 (80% of requests served from cache) and there are multiple ways to optimize CloudFront configuration for high CHR.
CloudFront policies
It is imperative to adjust the policies to your mobile application’s data patterns. Especially when it comes to caching and forwarding of headers, parameters, and cookies.
Origin settings
Always adjust your origin settings to accommodate the type of origin CloudFront is serving. Media streaming policy will always differ from static images or text files.
Origin settings can also help you improve your security posture by utilizing Origin Access Control (OAC) for S3 or reliability by introducing origin groups for failover scenarios.
Long tail content
While caching VOD media content is often impractical due to the size, other CloudFront configuration options can optimize the delivery. Storing the media content on multiple locations and using Lambda@Edge can hugely impact the performance by routing the mobile app user to the nearest region instead of always fetching from central source.
For a more dynamic mapping, Route53 latency policies can also be used for redirection.
Troubleshooting issues
CloudFront as a managed service can be notoriously hard to troubleshoot because of a lack of insights into traffic flow. While there is no easy trick to do this, in our experience, issues are mostly due to misconfiguration of one of the options above.
We recommend referring to AWS best practices for configuring CloudFront, using VPC flow logs, request tracing, and clearing the cache as the best ways to identify the root cause of issues.
Pricing
CloudFront utilizes a pay-as-you-go model, but also offers a great free tier that is refreshed each month – 1 TB of data, 10M requests and 2M CloudFront Functions and KeValueStore reads each.
Once free tier is exhausted the pricing is tiered by total data transferred. Actual numbers vary on regional group and can be checked on official AWS documentation.
Conclusion
With exceptional free tier and a plethora of features CloudFront is really a no-brainer anyone hosting their mobile applications in AWS. Once configured correctly it becomes set-and-forget service that will not only optimize your mobile applications, but also increase reliability and security posture.
![optimize-mobile-apps-cdn-2.webp](https://assets.ignit.group/optimize_mobile_apps_cdn_2_839810a7f0.webp)
Global Accelerator
AWS Global Accelerator enhances application performance by leveraging the AWS global network, which is optimized for speed and reliability. This network reduces the number of hops data must take to travel between your users and your application, significantly lowering latency and improving overall performance. The service dynamically routes user traffic to the most efficient path, ensuring that your applications respond quickly, even during peak traffic times.
In addition to the above, Global Accelerator key features also include:
- Static IP address for public endpoints
- Health checks and failovers
- Traffic management
Global Accelerator configuration
Creating a Global Accelerator is a straightforward process from the AWS console. We need ports, protocol, and regions that our endpoints will use. Once configured, we receive two anycast IP addresses that will route traffic to the closest configured AWS endpoint.
However, some best practices should be kept in mind while configuring the infrastructure around the service itself.
IP address preservation
Global Accelerator identifies each connection by a 5-tuple: source IP address, source port, destination IP address, destination port, and protocol. This can be useful for security and compliance restrictions, or for some advanced logic and personalization based on source IP of the mobile application.
If this feature is off, the source IP becomes NAT IP with Global Accelerator.
Connection collisions
These topics are covered in depth in official AWS blog posts, along with detailed explanations and possible mitigations. We will keep things simple here and just list things that need to be avoided while configuring Global Accelerators:
- Configuring the same load balancer with multiple accelerators
- Sending traffic through both Global Accelerator and public internet
- Enabling cross-zone traffic on load balancers behind Global Accelerator
Endpoint groups & routing
Endpoint groups are collections of AWS resources in a single region – EC2, NLB, ALB, or EIP. Traffic between these resources is split using routing algorithms.
When adding a resource to the group, a weight (0-255) needs to be defined. This number is used to determine what ratio of traffic will be sent to that endpoint. Exception for this rule is if the endpoint is unhealthy. It’s critical to set up good health checks in order to optimize routing.
Pricing
Pricing for Global Accelerator consists of a fixed monthly price plus a fee based on data transferred over the AWS network. Exact price varies between each region.
Conclusion
Mobile applications, particularly those requiring real-time data exchange like social media platforms, messaging apps, and mobile gaming, benefit significantly from AWS Global Accelerator. The service’s ability to reduce latency and improve connection stability ensures that mobile app users enjoy faster load times and smoother interactions, contributing to higher engagement and user retention.
Global Accelerator can lower latency by around 40% on average. For a more detailed speed comparison, a tool is available here.
References
Use the following links to explore details about these services and configurations: