Server-managed caching is the model for vertical scalability. You isolate data management in a relatively small number of cache servers and connect to them from thin clients, so many clients benefit from the management resources of only a few servers.
GemFire's client/server caching gives you dynamic server pool management, server load balancing and conditioning, logical server grouping, and automatic server failover for high availability.
The servers run in one distributed system. Each client runs in its own separate distributed system. The clients forward data requests to the servers that their caches cannot fulfill. The clients also forward client-side updates. Additionally, clients can register interest in server-side data, either by specifying the data keys or by registering queries that run continuously. In both cases, updates on the server side are automatically forwarded to the client.
This example shows a simple client/server installation with one worker client, that gets and puts data in its cache, and one consumer client, that just receives events from the server. Both clients are connected to a single cache server. The worker client requests data from the server. If the server does not have the data cached, it automatically runs a data loader to get it. The server returns the data to the worker client. The worker client then updates the data in its cache. The update is automatically distributed to the server. The server forwards all changes made by the worker client to the consumer client. Both clients have an asynchronous listener that reports local caching activity to standard out, so you can see what is happening.
|To run this example, you must have terminal sessions configured for the QuickStart examples, as described in Setting Up the Environment.|
- In one session, start the GemFire cacheserver:
The server starts in the background, sending information to the screen:
- In the same session, start the consumer client:
- When the consumer client asks you to start the worker client, start it in another session:
- Follow the instructions on the screens, noting the listener output from each client. When both clients have exited, stop the cacheserver:
Program and cache configuration file listings for the clients and the server, including the loader and listener declared in the Server.xml and Client.xml files. (The server is a GemFire cacheserver process and does not have a java listing.)