Latency and cost of Internet based services are a major concern for maintainers and to continue user's demands and to improve the availablility and scalability of the application encourages the usage of application level caching.
Dynamically generated web content is a major part of the web requests where the content changes based on the user request and due to this, the rate at which dynamic documents are delivered is often slower than static documents. Therefore, dynamic content place a load on the server which can lead to performance bottlenecks.
One of the techniques used to meet user's demands and reduce overhead on the servers is caching. Caching can reduce the user perceived latency and Internet traffic, and improve the scalability and availability of servers.
Application-level caching is placed on the server-side and typically uses a key-value in-memory store system to cache frequently accessed or expensive to compute data that remain not cached in other caching levels, lowering the load on database or services that are difficult to scale up.
Even though the concept is quite popular nowadays in applications, there are still designs which the developers integrating in system design need to take care of.
The design should pose four main questions :
- How to cache the data?
- What data should be cached?
- When should be the data be cached?
- Where the cached data should be put ?
- For how long should be data be cached and then cache should get updated?
There are lots of resources online on how to use caching optimally and also there are tools available.
For Caching, Memcached and Redis are popular solutions and are a critical web infrastructure component.
Caching Example on server side:
Caching on webserver can be implemented at many places depending on the architecture of the system.Depending on where caching is implemented, different types of content can be cached like the final HTML page , intermediate HTML or XML
fragments,database queries, or database tables.
The figure llustrates an example where an application level cache is used to lower the application workload. The application gets an HTTP request from the user and then goes to the webserver, then webserver tries to search the data in the cache, depending on how the cache is implemented. If the data is found in the cache it would result in a cache hit, otherwise it would be cache miss. In case of cache miss, webserver would query the data to the database itself, which could take a bit longer for the first time. But once it obtains the data from database, it would put it in cache again to serve the request from the user again in the future. Based on the caching strategy, the developers of the webserver would need to decide on how long would the data be cached.
Memcached and Redis are popular solutions and are a critical web infrastructure component.
If you liked reading the content, please do share it with other people who you think might be interested.
Also I do regularly post content on Twitter, do follow me @DhirenSerai for more.
Top comments (0)