3

What does it take to truly scale APIs ? Hint: it’s not all in the API layer

 1 year ago
source link: https://www.gigaspaces.com/blog/scale-api
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

What does it take to truly scale APIs ? Hint: it’s not all in the API layer

7min. read
iStock-1470130910.jpg

APIs eat the world – well maybe. But even if they haven’t gobbled the planet, it’s impossible to imagine today’s digital communication running without APIs. After all, APIs enable communication and integration between different software systems, they are indispensable in powering responsive and robust digital ecosystems. But all is not seamless for those who develop the application, services and the integrations between them. Specific challenges exist in maximizing APIs to provide excellent user experiences with top performance and ultra-fast response times. 

Two primary techniques are used to improve the responsiveness of apps and services: API scaling is one, and it’s often confused with the second, application acceleration, but their approaches are quite different. Application acceleration optimizes the performance of an application by reducing its response time, and improving its throughput to speed up data transfer, enabling a better user experience and more efficient utilization of resources. Some of the methods that are used to accomplish this include caching data, optimizing code, and using a CDN to deliver static content. Application acceleration concentrates on improving the performance of the application that is using the API. 

In contrast, API scaling is all about handling spikes and increases in API traffic and requests – the ability of the system to resize and adapt to changing loads. In this post we’ll focus on how API scaling increases the capacity of the API so it can handle more requests, and some of the ways to achieve this goal. 

API Performance Challenges

Harmonizing between apps, services and APIs means finding solutions for the following challenges.

Performance

Latency and throughput depend on the effectiveness of the underlying systems and overcoming their inherent limitations. Performance bottlenecks may occur due to inefficient code, excessive database queries, or slow third-party integrations.

API reliability and availability

APIs must be resilient to failures and seamlessly handle a variety of error scenarios.

Fluctuating user demands

APIs must be able to handle peaks and ensure seamless scalability and prevent overloading specific endpoints and to be able to ensure optimal performance.

Secure communication

All API communication must be secure and comply with regulatory standards.

Data Integrity and Consistency

Scaling APIs can lead to issues related to data integrity and consistency, especially in distributed systems where data is spread across multiple servers.

Discover how to address the challenge of serving fresh data to business applications here.

Cache Invalidation

Implementing caching strategies can improve API response time, but cache invalidation becomes a challenge when the data updates frequently.

The following diagram summarizes many of these problematic issues: 

Diagram

An additional challenge for many organizations results from the difficulty in resolving performance and scale challenges that are rooted in APIs that are running over unscalable core systems. While modern apps tend to live mostly in the cloud, many still rely on data that resides in legacy systems. The performance of the apps and services is then held back by the slowest performing component – in this case, the legacy SoRs. 

API scaling best practices

To maximize API scaling, start with a foundation of elastic and modular architectures. A number of methodologies and technologies can be used – sometimes a combination of some of these options can be implemented. 

Adding new nodes, or instances of a resource such as VMs or database replicas, to divide the load between several endpoints; scaling out improves a system’s performance for extended periods, even permanently.

Vertical scaling (scale up and down)

This scaling increases the hardware capacity of each server during high demand periods, to handle increased data loads by adding more CPU power, memory, or storage, and allowing the system to scale down when the demand subsides.

Hybrid scaling

A new twist that combines horizontal and vertical scaling to achieve the optimal balance of performance, cost, and availability. This type of scaling requires more planning and testing, to balance the trade-offs between both methods and to ensure the compatibility and integration of the servers. Hybrid scaling leverages the advantages of both approaches and mitigates their challenges, such as scaling out to handle peak demand or unexpected spikes, and scaling up to improve the performance or reduce the cluster size. Another way to implement hybrid scaling is to use vertical scaling to boost the performance and reliability of core servers, such as database or application servers, and to use horizontal scaling to increase the scalability and availability of edge servers, such as web or proxy servers. 

Caching

A cache can hold responses to common API calls, which reduces the need to compute the same response over and over. 

Throttling

Setting limits on the number of requests a client can make to the API within a specific time period prevents excessive calls. This is designed to protect core systems from peaks that they cannot handle, and assure Quality of Service (QoS) at the expense of limited concurrent users capacity. 

Load Balancing

This process distributes incoming API requests across multiple servers to prevent overloading a single server; ensures even resource utilization and improved fault tolerance. 

Asynchronous APIs

This method distributes requests across multiple servers, which allows for non-blocking, concurrent execution of operations by allowing applications to handle more requests without having to increase the number of servers.

How an Operational Data Hub augments API scaling 

Due to the sheer increase in APIs, an innovative approach to enable API scaling is to implement an Operational Data Hub – also known as a Digital Integration Hub. An operational data hub such as Smart DIH, also available as a service, decouples APIs from their systems of record (SoRs) so that unscalable core systems no longer affect performance. It consolidates data from multiple SoRs into a low-latency, high-performance centralized distributed data store that is accessed by APIs and events. Smart DIH is an out of the box implementation that enables delivery of a high performance, ultra-low latency, and an always-on digital experience. 

Diagram

Sample Smart DIH Reference Architecture

Smart DIH runs natively on Kubernetes, on-premises, on the hyperscalers native Kubernetes services, and on both. Smart DIH is built using microservices principles, hence it easily benefits from Kubernetes’ auto-scaling, service discovery and efficient traffic distribution across the different Pods. 

Smart DIH supports API scaling and load balancing, leveraging the scalability and load balancing capabilities of the underlying data grid. As demand fluctuates the grid ensures that messages are distributed evenly across multiple nodes or containers. This allows the system to handle large volumes of messages and dynamically scale, offering high throughput and scalability. Smart DIH’s architecture also provides automatic failover and recovery capabilities to ensure that applications remain highly available and resilient in the event of a failure or outage. 

banner

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK