Skip to content

Commit dc74fa4

Browse files
Merge pull request #2942 from syncfusion-content/882106-Redis-Cache
882104 - Add UG for scaling in collaborative editing
2 parents cee535a + 7557a2a commit dc74fa4

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

ej2-asp-core-mvc/document-editor/collaborative-editing.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private ActionInfo AddOperationsToTable(ActionInfo action)
296296

297297
#### Add Web API to get previous operation as a backup to get lost operations
298298

299-
On the client side, messages broadcasted using SignalR may be received in a different order, or some operations may be missed due to network issues. In these cases, we need a backup method to retrieve missing records from the database.
299+
On the client side, messages broadcast using SignalR may be received in a different order, or some operations may be missed due to network issues. In these cases, we need a backup method to retrieve missing records from the database.
300300
Using the following method, we can retrieve all operations after the last successful client-synced version and return all missing operations to the requesting client.
301301

302302
```csharp
@@ -305,7 +305,7 @@ public async Task<ActionInfo> UpdateAction([FromBody] ActionInfo param)
305305
try
306306
{
307307
ActionInfo modifiedAction = AddOperationsToTable(param);
308-
//After transformation broadcast changes to all users in the gropu
308+
//After transformation broadcast changes to all users in the group
309309
await _hubContext.Clients.Group(param.RoomName).SendAsync("dataReceived", "action", modifiedAction);
310310
return modifiedAction;
311311
}
@@ -338,8 +338,47 @@ private ActionInfo AddOperationsToTable(ActionInfo action)
338338
}
339339

340340
```
341+
## How to perform Scaling in Collaborative Editing.
342+
343+
As the number of user increases, maintaining responsiveness and performance becomes challenging. Scaling tackles this by distributing the workload across resources. You can scale the collaborative editing application using either ```Azure SignalR service or Redis backplane service```
344+
345+
### 1. Scaling with Azure SignalR
346+
347+
Azure SignalR Service is a scalable, managed service for real-time communication in web applications. It enables real-time messaging between web clients (browsers) and your server-side application(across multiple servers).
348+
349+
Below is a code snippet to configure Azure SignalR in an ASP.NET Core application using the ```AddAzureSignalR``` method
350+
351+
```csharp
352+
builder.Services.AddSignalR() .AddAzureSignalR("<your-connection-string>", options => {
353+
// Specify the channel name
354+
options.Channels.Add("document-editor");
355+
});
356+
```
357+
358+
### 2. Scaling with Redis backplane
359+
360+
Using a Redis backplane, you achieve horizontal scaling of your SignalR application. The SignalR leverages Redis to efficiently broadcast messages across multiple servers. This allows your application to handle large user bases with minimal latency.
361+
362+
In the SignalR app, install the following NuGet package:
363+
* ` Microsoft.AspNetCore.SignalR.StackExchangeRedis`
364+
365+
Below is a code snippet to configure Redis backplane in an ASP.NET Core application using the ```AddStackExchangeRedis ``` method
366+
367+
```csharp
368+
builder.Services.AddSignalR().AddStackExchangeRedis("<your_Redis_connection_string>");
369+
```
370+
Configure options as needed:
371+
372+
The following example shows how to add a channel prefix in the ConfigurationOptions object.
373+
374+
```csharp
375+
builder.Services.AddDistributedMemoryCache().AddSignalR().AddStackExchangeRedis(connectionString, options =>
376+
{
377+
options.Configuration.ChannelPrefix = "document-editor";
378+
});
379+
```
341380

342381

343382
Full version of the code discussed about can be found in below GitHub location.
344383

345-
Github Example: [`Collaborative editing examples`](https://github.com/SyncfusionExamples/EJ2-Document-Editor-Collabrative-Editing)
384+
GitHub Example: [`Collaborative editing examples`](https://github.com/SyncfusionExamples/EJ2-Document-Editor-Collabrative-Editing)

0 commit comments

Comments
 (0)