Building a faster Web application with caching

Source: Internet
Author: User

Introduction: Web Developers who use Java™ technology can use the caching utility to quickly improve the performance of their applications. The Java Cache system (Java Caching SYSTEM,JCS) is a powerful distributed caching system for Java applications, a highly configurable tool with a simple API. This article outlines JCS and shows you how to use it to improve the speed of your WEB application.

Many WEB applications are rewritten based on desktop applications; Ideally, the speed and scalability of these applications should be the same as the desktop version. Almost all WEB applications can benefit from the growth in speed. Data that is cached frequently but rarely changed is an effective way to reduce user latency. A utility can help you achieve this goal by using Easy-to-use APIs to easily handle data caching. Open source JCS (that is, an Apache Jakarta project) is one such tool. This article explains how to configure and use JCS to cache data for a WEB application.

JCS Overview

JCS is a caching system written in the Java language that you can use to create Java desktops and WEB applications. It provides convenient mechanisms for storing data in the cache, removing data from the cache, and so on.

You can use JCS to store cached data in a variety of specified data regions. JCS defines 4 types of core zones: Memory area, disk area, perimeter area, and remote zone. These core areas can be used in conjunction to gain greater flexibility in how to store cached data and where to store the cached data. You can specify which zone to use for the first time, and where to move to when a failure occurs.

Memory Area

The memory area is a pure memory cache region that uses the most recent minimum algorithm (least recently USED,LRU). When the memory cache area is full, LRU first deletes the least recently used cache data. This data region performs well, and most JCS users designate it as the default cache area to use first.

Disk Area

The disk area is caching data on the WEB server's file disk. To improve performance, JCS stores the cached data key in memory while storing the actual cached data on the file disk. In a typical JCS configuration that uses the memory area first, any data that cannot be saved in the memory area is written to the disk area.

Perimeter area

The perimeter area provides a configurable way to distribute cached data among multiple servers. The cached data server must have an open port for listening, and a socket connection must be created. There is a potential problem with this area because it does not guarantee the consistency of data between the caches. However, this problem does not occur if the area is used as planned.

Remote Zone

The remote zone provides a cache area that uses the remote method call (RMI) API. This area uses a remote server to process cached data. This remote caching server can be used by multiple JCS client applications to store cached data. Some listeners are defined to collect requests from clients and servers. This cache area helps reduce the overhead of serialization and multiple connection points.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.