Reliable distributed computing systems and applications have become the cornerstone of outstanding business , Especially in automating and managing mission critical business processes and providing services to customers . As developers and administrators of these systems and Applications , You should provide a variety of information technologies (IT) Solution , To ensure that you have the most efficient system .

This includes for the system / Application performance , reliability , Usability and scalability design , Testing and implementing strategies, etc , Provide a satisfactory level of service to end users . Caching is one of many very basic but effective application delivery technologies you can rely on . Before proceeding , Let's take a brief look at what caching is , Where or how to apply caching and its benefits ?

What is caching or content caching ?

cache ( Or content caching ) It's a widely used technology , It stores a copy of the data in a temporary storage location ( Also known as caching ) in , So compared to retrieving data from raw storage , It's easy , Access data quickly . According to the purpose and type of cache , The data stored in the cache may include files or file fragments ( for example HTML file , Script , Images , Documents, etc. ), Database operations or records ,API call ,DNS Records, etc. .

Caching can be in the form of hardware or software . Software based caching ( This is the focus of this article ) It can be implemented on different layers of the application stack .

Caching can be imposed on the client side ( Or in the application presentation layer ) in , for example , Browser caching or cached applications ( Or offline mode ). majority ( If not all ) Modern browsers come with HTTP Cache implementation . When you visit Web Application to enable you to view the latest data or content on the website or app , It's not when browsers use old copies of locally stored content , You may have heard the popular phrase “ Clear cache ”.

Another example of client caching is DNS cache , It happens in the operating system (OS) Level . It's about the operating system or Web The browser used to be DNS Find temporary storage of information .

You can also use agents in LAN or WAN Implement caching at the network level in . A common example of this caching is CDN( Content delivery network ), It is Web A globally distributed network of proxy servers .

Third , You can also implement caching on the source or back-end servers . There are different forms of server level caching , Include :

  • Web Server cache ( For caching images , file , Script etc. ).
  • Application caching or memory ( Used to read files from disk , To read data from another service or process or from API Request data, etc ).
  • Database cache ( Provide common data ( For example, the requested database row , Query results and other operations ) Memory access for ).

Please note that , Cache data can be stored in any storage system , Include database , file , System memory, etc , But it should be faster than the main source . In this regard , Memory caching is the most efficient and commonly used form of caching .

Why use caching ?

Caching has many advantages , Include :

  • At the database level , It improves the read performance of cached data to microseconds . You can also use write back caching to improve write performance , under these circumstances , Data is written to memory at specified intervals , Then write it to disk or primary storage . But its data integrity aspect can have a disastrous impact . for example , When the system crashes just before data is committed to primary storage .
  • At the application level , Caching can store frequently read data in the application process itself , This reduces the data lookup time from a few seconds to a few microseconds , Especially on the Internet .
  • Considering the performance of the entire application and server , Caching helps reduce the load on the server , Latency and network bandwidth , Because the cached data is provided to the client , This improves the response time and delivery speed to the client .
  • Caching also allows content availability ( Especially through CDN), And many other benefits .

In this paper , We will review some of the applications in Linux The top open source tool for server-side caching ( Applications / Database caching and proxy caching ).

1. Redis

Redis( complete REmote DIctionary Server) It's a free one , Open source , Fast , High performance , Flexible distributed memory computing system , Can be found in most ( If not all of it ) Used in programming languages .

It's data structure storage in memory , As a cache engine , In memory persistent disk database and message broker . Even though Redis Is in Linux( Recommended deployment platform ) and OS X For development and testing , But it can also be used in other POSIX System ( for example * BSD) Run in , Without any external dependencies .

Redis Supports many data structures , Like strings , Hash , list , aggregate , Sort set , Bitmap , Flow, etc. . This allows programmers to use specific data structures to solve specific problems . It supports automatic manipulation of its data structure , For example, appending to a string , Push elements to the list , Increase the hash value , Calculate set intersection, etc .

Its main functions include Redis Master slave copy ( By default, it's asynchronous ), Use Redis Sentinel Provides high availability and automatic failover ,Redis colony ( You can scale horizontally by adding more cluster nodes ) And data partitioning ( In more than one Redis Data is allocated between instances ) ). It also has a pair of things ,Lua Script , A range of persistence options and clients - Server communication encryption support .

As an in memory but persistent disk database ,Redis Works best with in memory datasets . however , You can use it with a disk database , for example MySQL,PostgreSQL etc. . for example , You can go to Redis Get a large number of small data write operations in , And keep other data blocks in the disk database .

Redis Support security in a variety of ways : One is to use “ Protected mode ” Function to protect Redis Instances are not accessed by external networks . It also supports clients - Server authentication ( Configure the password in the server and provide the password in the client ) And all the communication channels ( For example, client connections , Copy links and Redis Cluster Bus protocol, etc ) Upper TLS.

Redis There are many use cases , Including database caching , Full page caching , User session data management ,API Response storage , Release / Subscription messaging system , Message queuing and so on . These can be applied to games , Social networking applications ,RSS summary , Real time data analysis , User recommendation, etc .

2. Memcached

Memcached It's a free one , Open source , Simple but powerful distributed memory object caching system . It's a key value store in memory , Used to store a small amount of data , For example, database calls ,API The result of a call or page rendering . It can be similar to Unix Operating system of ( Include Linux and OS X) Up operation , It can also be in Microsoft Windows Up operation .

As a developer tool , It's designed to cache content ( By default, it is the least recently used (LRU) cache ) To improve the dynamics Web The speed of the application , Thus reducing the database load on the disk – It acts as a short-term memory application for the following tasks . It provides the most popular programming language of API.

Memcached Support string as the only data type . It has clients - Server architecture , Half of that logic happens on the client side , The other half happens on the server side . It is important to , The customer knows how to select the server to write to or read from for the project . Besides , If the client cannot connect to the server , The client knows what to do .

Although it's a distributed caching system , So cluster support , but Memcached Servers are disconnected from each other ( namely , They don't know about each other ). It means there is no such thing as Redis This kind of replication supports . They also know how to store and retrieve projects , Manage when to evict or reuse memory . You can increase the available memory by adding more servers .

from Memcached 1.5.13 Start , It supports the adoption of TLS Authentication and encryption , But this function is still in the experimental stage .

3. Apache Ignite

Apache Ignite, It's also a free open source code , Horizontally scalable key value storage in distributed memory , Cache and multi model database system , It provides powerful processing API, Can be used for computing on distributed data . It's also an in memory data grid , It can be used in memory , with Ignite Use native persistence with . It can be similar to UNIX The system of ( for example Linux and Windows) Up operation .

It has multiple layers of storage , complete SQL Support for and across multiple cluster nodes ACID( Atomicity , Uniformity , Isolation, , Durability ) Business ( Only in key values API Supported at the level ), Co processing and machine learning . It supports any third party database ( Including any RDBMS( for example MySQL,PostgreSQL,Oracle Database etc. ) or NoSQL Storage ) Automatic integration of .

The important thing is to pay attention , Even though Ignite Used as a SQL data storage , But it's not exactly SQL database . Compared with traditional database , It can obviously handle constraints and indexes . It supports primary and secondary indexes , But only the main index refers to mandatory uniqueness . Besides , It does not support foreign key constraints .

Ignite Security is also supported by allowing you to enable authentication on the server and provide user credentials on the client side . And support SSL Socket communication , In all of Ignite Provide secure connections between nodes .

Ignite There are many use cases , Including caching systems , System workload acceleration , Real time data processing and Analysis . It can also be used as a graphics centric platform .

4.Couchbase Server

Couchbase Server It's still an open source code , Distributed ,NoSQL Document oriented participatory database , With the key - Value formats store data as items . It can be Linux as well as Windows and Mac OS X And other operating systems . It uses a rich document oriented query language N1QL, The language provides powerful query and index services , To support sub millisecond operations on data .

Its remarkable feature is fast key value storage with managed cache , Special indexer , Powerful ​​ The query engine of , Scale out architecture ( Multidimensional extension ), Big data and SQL Integrate , Full stack security and high availability .

Couchbase Server Comes with native multi instance cluster support , The cluster manager tool coordinates all node activities , It only provides cluster wide interfaces to clients . It is important to , You can add , Delete or replace nodes , Without having to shut down . It also supports data replication across cluster nodes , Selective data replication across data centers .

It uses dedicated Couchbase Server port , Different authentication mechanisms ( Use credentials or certificates ), Role-based access control ( To check each authenticated user for the system defined roles assigned to them ), Audit , Logs and conversations , adopt TLS Achieve security .

Its use cases include a unified programming interface , Full text search , Parallel query processing , Document management and indexing, etc . It's designed for large interactive Web, Mobile and IoT Applications are designed to provide low latency data management .

5.Hazelcast IMDG

Hazelcast IMDG( In memory data grid ) It's open source , Lightweight , Fast and scalable in memory data grid middleware , It can provide elastic and scalable distributed in memory computing .Hazelcast IMDG You can also do it in Linux,Windows and Mac OS X And installed Java On any other platform of . It supports a variety of flexible language native data structures , for example Map,Set,List,MultiMap,RingBuffer and HyperLogLog.

Hazelcast It is reciprocal. , Support simple scalability , Cluster settings ( Has the ability to collect statistics , adopt JMX Options for monitoring protocols and managing clusters with useful utilities ), Distributed data structures and events , Data allocation and transaction functions . It's also redundant , Because it can keep a backup of each data entry on multiple members . To expand the cluster , Just start another instance , Data and backup are automatically and evenly balanced .

It provides a useful set of API To access CPU, To achieve maximum processing speed . It also provides information from Java Distributed implementation of a large number of developer friendly interfaces , for example Map,Queue,ExecutorService,Lock and JCache.

Its security features include cluster membership and client authentication , And based on JAAS The security function of client can check the access control of client operation . It also allows for blocking socket connections and remote operations performed by clients , Socket level communication between cluster members is encrypted and enabled SSL / TLS Socket communication . But according to official documents , Most of these security features are available in the Enterprise Edition .

Its most popular use cases are distributed in memory caching and data storage . however , It can also be deployed for Web Session clustering ,NoSQL Replace , parallel processing , Simple messaging and so on .

6.Mcrouter

Mcrouter Is a free open source Memcached Protocol router , Used to extend by Facebook Developed and maintained Memcached Deploy . It has Memcached ASCII agreement , Flexible routing , Multi cluster support , Multi level cache , Connection pool , Multiple hash schemes , Prefix routing , Replication pool , Production flow shadow , Online reconfiguration and target health monitoring / The ability to automatically fail over .

Besides , It supports cold cache preheating , Rich statistics and debugging commands , Reliable quality of service for delete streams , The larger value , Broadcast operation , And IPv6 and SSL Support .

It's already in Facebook and Instagram As the core component of the caching infrastructure , The peak processing is close to per second 50 Million requests .

7.Varnish Cache

Varnish Cache It's located in Web Open source flexibility between client and original server , Modern and versatile Web Application Accelerator . It can be in all modern times Linux,FreeBSD and Solaris( only x86) Run on the platform . It's a great caching engine and content Accelerator , You can deploy it in Web The server ( Such as NGINX,Apache etc. ) In front of , To listen to the default HTTP Port to receive client requests and forward them to Web The server , And deliver Web The server responds to the client .

While acting as an intermediary between the client and the original server ,Varnish Cache Provides many benefits , The basic element is to Web The content is cached in memory , To lessen Web Load the server and improve delivery to clients .

Received from client HTTP After the request , It forwards the request to the back end Web The server .Web After the server responds ,Varnish Cache content in memory , And pass the response to the client . When the client requests the same content ,Varnish It will be served from the cache promoted application response . If it doesn't provide the content in the cache , Forward the request to the back end , The response is then cached and passed to the client .

Varnish have VCL(Varnish Configuration language , A flexible domain specific language ), Used to configure how requests are handled and Varnish modular (VMODS), They are Varnish Cache An extension of .

On the safety side ,Varnish Cache Supported by VMODS Logging , Request check and limit , Authentication and Authorization , But it lacks the right to SSL / TLS Native support for . You can use Hitch or NGINX etc. SSL / TLS The agent for Varnish Cache Enable HTTPS.

You can also Varnish Cache Used as a Web Application Firewall ,DDoS*** Defense procedures , Hot link protector , Load balancer , Integration point , Single sign on gateway , Authentication and authorization policy mechanism , Quick fix for unstable back ends and HTTP Request router .

8.Squid Caching Proxy

Squid It's another one for Linux The free , Open source , Outstanding and widely used proxy and cache solutions . It's functional Web Proxy cache server software , Can be a popular network protocol ( Include HTTP,HTTPS and FTP) Provides proxy and caching services . It can also be used in other UNIX The platform and Windows Up operation .

It's like Varnish Cache equally , It receives requests from clients and delivers them to the specified back-end server . When the back-end server responds , A copy of the content is stored in the cache , And pass it on to the client . Future requests for the same content will be processed from the cache , So that the content can be delivered to the client faster . therefore , It can optimize the data flow between client and server to improve performance , And cache common content to reduce network traffic and save bandwidth .

Squid It has some functions , For example, the load is distributed on the hierarchy of mutual communication of proxy servers , Generate about Web Data using patterns ( for example , Statistics about the most visited sites ), Enables you to analyze , Capture , prevent , Replace or modify the message being proxied .

It also supports security features , For example, rich access control , Authorization and authentication ,SSL / TLS Support and activity logging .

9.NGINX

NGINX( Pronunciation is Engine-X) It's an open source code , High performance , Full featured and very popular integration solution , Used for setting up Web Infrastructure . It is HTTP The server , Reverse proxy , Mail proxy server and general TCP / UDP proxy server .

NGINX Provides basic caching capabilities , The contents of the cache are stored in the persistent cache on disk .NGINX The interesting thing about content caching in is that , When it can't get fresh content from the original server , It can be configured to pass stale content from its cache .

NGINX Provides a variety of security features to protect your Web System , These functions include SSL End , Use HTTP Basic authentication restricts access to , Authentication based on the result of the subrequest ,JWT Authentication , Restrictions on agents HTTP Access to resources , Geographically restricted access , And more .

It is usually deployed as a reverse proxy in the application stack , Load balancer ,SSL finalizers / Security gateway , Application Accelerator / Content caching and API gateway . It's also used for streaming media .

10. Apache Traffic Server

Last but not least , We have Apache Traffic Server, This is an open source , Fast , Scalable and scalable cache proxy server , Support HTTP/1.1 and HTTP/2.0. It's designed to help businesses ,ISP(Internet Server Provider ), Backbone providers and others cache frequently accessed content at the edge of the network to improve network efficiency and performance .

It supports HTTP / HTTPS Forward and reverse proxies for communication . It can also be configured to run in one or two modes at the same time . It has a persistent cache , plug-in unit API; Support ICP(Internet Cache protocol ),ESI( Including edges );Keep-Alive etc. .

In terms of security ,Traffic Server Support client access control , The method allows you to configure clients that allow proxy caching , The connection between the client and itself and between itself and the original server SSL End . It also supports authentication and basic authorization through plug-ins , Record ( Every request received and every error detected ) And monitoring .

Traffic Server Can be used as Web Proxy cache , Forward agency , Reverse proxy , Transparent proxy , Load balancers or in cache hierarchies .

summary

Caching is the most useful and long-standing Web One of the content delivery technologies , Its main purpose is to increase the speed of a website or application . Because the cached data is provided to the client , So it helps to reduce server load , Latency and network bandwidth , This improves the application response time and delivery speed to the client .

author :Aaron Kili translator :Yue Yong
From the original :https://www.tecmint.com/open-source-caching-tools-for-linux/