Load-balanced environment
- 5 minutes to read
On average, the standard server configuration of Xeon E3-1276 v3 with 16 Gb RAM and SSD allows you to support up to 100 concurrent users of Customer's Canvas. If you find that Customer's Canvas is slower than expected, then you can try to optimize the speed using the following three approaches:
- Deploy Customer's Canvas on a load-balanced environment.
- Adjust the website settings to eliminate cold-start delays.
- Move Customer's Canvas from a server where your site is hosted to a separate one.
This article dwells on the implementation of the first approach.
Deployment on a Load-balanced Environment
The load-balanced environment is a server architecture that allows for scaling system performance. Such an environment consists of two major parts:
- A load balancer, accepting all requests to the web application and distributing them between application servers.
- Application servers, hosting the application instances and processing requests redirected by the load balancer.
From the outside looking in, this setup appears as if the application were launched at one server since all user requests are sent to the load balancer, which has a single IP address. In the background, different requests are processed by different servers, which allows you to distribute the load and increase the processing speed.
You can install Customer's Canvas in such an environment, but this requires some additional setup. Customer's Canvas requires all design templates, galleries, and user files to be located on the server where the editor is deployed. To get around this, you may need to set up network storage to store all the common files and link it to every Customer's Canvas instance deployed to application servers. This way, all instances work with the same version of files except for the local cache. All requests to Customer's Canvas's back end initiated by a user within a single session should be processed by the same application server as it needs access to files located in the server's local cache. You need to design your application in a way that the load balancer redirects all user requests within a single product editing session to the same application server.
Your load balancer may implement sharding, using your user's ID as a shard key. For example, if your user IDs are numeric values, then you can determine on which server the user should work, using the remainder of the integer division of the user ID by the number of servers (shards). This way, the remainder will correspond to the server number.
The following scheme illustrates this workflow.
Note
Every Customer's Canvas instance requires a separate license.
To apply this distributed structure:
- Allocate a network server and make it available to all your application servers.
- Create the ProductTemplates, UserDataFolder, and PublicGalleryFolder folders to store templates and images.
- Install Customer's Canvas instances on application servers and link the folders to them using symbolic links.
- Implement and configure your Load balancer to redirect users to a particular instance during a single session.
Linking the Folders
A symbolic link (symlink) is a file system object that points to another file system object. To map a folder located in network storage to a local folder, you can run the mklink
command on your application servers.
mklink /d C:\shared\PublicGalleryFolder \\server\CustomersCanvas\PublicGalleryFolder
After that, you need to specify such folders in the AppSettings.config file.
<appSettings>
<add key="PublicGalleryFolder" value="c:\shared\PublicGalleryFolder" />
<add key="UserDataFolder" value="c:\shared\UserDataFolder" />
<add key="DesignFolder" value="c:\shared\ProductTemplates\designs" />
<add key="MockupFolder" value="c:\shared\ProductTemplates\mockups" />
<add key="WatermarkFolder" value="c:\shared\ProductTemplates\watermarks" />
<add key="DesignImagesFolder" value="c:\shared\ProductTemplates\designImages" />
</appSettings>
Note that you can organize external storage for state files and avoid storing these files in UserDataFolder
. In this case, you need to implement a controller processing requests to push and pull state files.
Also, Customer's Canvas allows you to move fonts and color profiles to separate storage locations. In this case, you need to configure the corresponding folders in the Aurigma.DesignAtoms.config file.
<Aurigma.DesignAtoms>
<add key="CmykColorProfileFileName" value="c:\shared\cmykColorProfile.icc" />
<add key="FontDirectory" value="c:\shared\Fonts" />
</Aurigma.DesignAtoms>
Network Load Balancing
Note
Customer's Canvas requires the 50 MB/s access speed to the network storage.
Starting from version 4.2, Customer's Canvas requires either a dedicated SQL Server or an Azure SQL Database (the Standard tier).
Starting from version 7.0, Customer's Canvas uses a TokenService microservice instead of the SQL Database.
If you deploy Customer's Canvas to Microsoft Azure, you can use Azure Internal Load Balancer. In this case, set Session persistence to Client IP
and Idle timeout to 30 minutes
.
If you deploy Customer's Canvas to your own servers, you can use the Network Load Balancing feature in Windows Server. In this case, set Affinity to Single Affinity
and Timeout to 30 minutes
or more.
To enable proper URLs that link to proof images and high-resolution outputs, set the AppUrl
parameter to your application server's address in AppSettings.config.
<appSettings>
<add key="AppUrl" value="https://8.8.8.8/" />
</appSettings>
Authentication via TokenService
Authentication in the Design Editor works using tokens. In load balancing scenarios when multiple Design Editor instances are deployed on one or more machines, TokenService must be used for the operation of the authentication subsystem. You must also use TokenService when the IIS Application Pool is configured in Web Garden mode with Maximum Worker Process set to more than 1.
Deploying TokenService
TokenService is a separate service deployed as a web application. You can find this application in the TokenService.zip distribution package.
The following components are required to deploy TokenService to a Windows Server:
- Microsoft .NET Framework 4.8.0
- IIS 7 or higher with ASP.NET 4.5 running in Integrated mode
The operation of TokenService does not involve high loads, therefore it is recommended to deploy TokenService on the same machine as the Design Editor.
To support multiple Design Editor nodes working in the same bundle, TokenService must be deployed in a single instance.
Configuring TokenService
When deploying the TokenService, you must define the ApiKey
parameter in the appSettings
section of the web.config file.
<appSettings>
<add key="ApiKey" value="your-api-key" />
</appSettings>
Configuring DesignEditor
The Design Editor has two parameters in AppSettings.config to work with TokenService:
TokenServiceEndpoint
- the address of the deployed TokenService application.TokenServiceApiKey
- theApiKey
defined in the TokenService config.
Uncomment these parameters and specify your values.
...
<!-- Remote Token Service -->
<!-- <add key="TokenServiceEndpoint" value="https://localhost/token-service"/> -->
<!-- <add key="TokenServiceApiKey" value="your-api-key"/> -->