Ucommerce Scalability Options
Ucommerce has several scalability options to achieve better performance as the demand increases.
The Ucommerce environment can be configured as:
- Standalone, all roles on one machine.
- Split, one, some or all roles have its own machine.
Every environment role can achieve better performance by:
- Scaling vertically
- Scaling horizontally
Environment Roles
Ucommerce environment has the following roles:
- SQL Database Server
- NHibernate 2nd Level Cache Server
- Web Server
- Search index
Standalone machine for all roles
By default, all roles run on the same machine. This is great for development environments, as you are up and running in no time.
For a production environment, this can be a problem if the machine does not have enough resources. Since all the roles compete for the same resources (CPU, RAM, and DISK), any one of them can starve the others.
Scaling Vertically
“To scale vertically (or scale up) means to add resources to a single node in a system, typically involving the addition of CPUs or memory to a single computer.” (Wikipedia)
This is the easiest way to achieve better performance. Ideally, do a profiling to figure out what kind of resource the environment is running low on.
Split one/more/all roles to their own Machines
Ucommerce offers a gradual way of moving roles to their own machine. You can start with one and move additional roles to free up resources as needed.
Splitting the search index to a dedicated location
To offer support for horizontal scaling the search indexes must be scaled to its own instance. Out of the box this is possible by configuring the ElasticSearch index rather than the (non horizontal scalable Lucene search index) Ucommerce installs with Lucene out of the box which means that everything just works, but when you want to move to a scaled environment it is needed that you swap the search index to ElasticSearch instead. This means that regardless of you running auto scaling, fixed scaling on content delivery or a third horizontal scaling, the search index is up to date for each instance. Configuring Lucene for this setup should be considered bad praactice and should not be done. So consider scaling to ElasticSearch a prerequisite for horizontal scaling of the platform.
To enable Elasticsearch you need to install and configure the connection from Ucommerce.
Moving SQL Database Server to its own machine
SQL Server is usually very resource intensive, and moving it to its own machine is usually a good first step. Just move the Ucommerce database to the new server and change the connection string in web.config on the Web Server. Read more here.
Moving NHibernate 2nd Level Cache to its own machine
Ucommerce caches Data Entities in a shared cache, this is by default run on the Web Server.
The NHibernate 2nd Level Cache is provider-based, and Ucommerce uses SysCache as the default provider. SysCache uses the ASP.NET cache by default that uses the Web Servers memory.
To free up RAM, this cache can be moved to its own machine. Using one of the other providers (Redis, MemCached, NCache etc.)
Web Server
This leaves the Web Server using all the available resources, for serving web requests.
Vertically Scaling a Split Role per Machine Environment
Each of the role machines can individually be scaled vertically. If the bottleneck is the SQL Server, adding more resources to it would make sense up to a certain point. If the Web Server does not handle enough requests, adding more CPU or RAM will help increase performance.
Horizontally Scaling a Split Role per Machine Environment
Scaling vertically can be increasingly expensive since better hardware in a single machine gets incrementally more expensive.
The technologies (SQL Server, and many of the 2nd Level Cache Providers) used by Ucommerce supports horizontal scaling. It is out of scope for this article on how to do this, please reference their respective documentation.
Horizontally Scaling of Ucommerce on the Web Server
Ucommerce running on the Web Server can be distributed to multiple machines, as long as any shared state is kept at a single source of truth. Shared state co-insides with the Roles (SQL Server, and NHibernate 2nd Level Cache, search index), and needs to be accessible from all Web Server machines.
It is possible to horizontally scale the Web Servers, without scaling any of the other roles. You could set up a single machine with SQL Server, and NHibernate 2nd Level Cache, and then add multiple Web Servers all pointing to that machine.
Summary
Ucommerce has many options for improving performance and support scaling (both vertical and horizontal) and split per role out of the box.