Components required in a multi-server environment and how they are installed
Please read the system requirements to verify the compatibility of the hosting environment and the Litium system before installing Litium.
This article describes the extra components required in a multi-server environment, for example a web farm or multiple developer computers using the same database.
Service bus
When you have multiple applications running in a web farm, the applications need to communicate with each other. For this purpose, a service bus is used. The service bus replicates events to multiple Litium applications running on the same server, or on multiple servers.
Distributed caching
Distributed caching can be applied to single or multiple Litium applications running on the same server, or on multiple servers, to reduce the memory usage. The distributed cache is located outside the Litium application, and the cache is shared by multiple applications.
The distributed cache is avaliable by injecting the IDistributedCache interface.
It is also possible to inject and use the DistributedMemoryCacheService. This cache service uses a hybrid solution where data is stored both in a short (2 minute) in memory cache as well as in a longer (24 hour) distributed cache.
An example on how to implement the DistributedMemoryCacheService with Redis can be found in Litium developer training material.
Distributed concurrency lock
Distributed concurrency lock is used to ensure that not the same operation can execute on the same time to avoid concurrent update problems or to ensure that an operation only is executed in one of multiple applications at the same time. Default implementation for distributed concurrency lock is using the common storage for files.
The distributed concurrency lock is avaliable by injecting the DistributedLockService and use the service to wrap the locked code in a using-statement:
using (_distributedLockService.AcquireLock(key, TimeSpan.FromSeconds(10)))
{
// work with the locked item
// ...
}
An example on how to implement the DistributedLockService with Redis can be found in Litium developer training material.
Two alternatives
From Litium 7.3, there are two alternatives to set up a multi-server environment:
- Microsoft Azure Service Bus - supports only the service bus
- Redis - supports the service bus, distributed caching and distributed concurrency lock
The installation is described in the two articles that are linked below.