Skip to main content

Microsoft Teams Assignments Service’s Journey to .NET 6

The Assignments and Grades features in Teams for Education allow educators to assign tasks, work, or quizzes to their students. Those with school aged children may know this Microsoft Teams feature well already, but you can learn more about it on the Microsoft Education Blog.

The Assignments backend service handles a variety of workloads (examples include: serving static content, providing REST APIs over heterogenous data sources, asynchronous worker process, and batch processors handling scheduled tasks). It was built on .NET (predominantly, ASP.NET WebAPI running on .NET 4.7.2). Over the past five years, classrooms around the world have been going through a technological transformation. Most recently, with the switch to remote and hybrid learning due to the COVID-19 pandemic, the Assignments service has seen a roughly 4000% increase in usage. Over the past couple years, we have attempted to deal with the exponential traffic increase in a variety of ways, including algorithmic optimizations, additional caching layers, and low-level serialization optimizations. We have also had to scale out our compute resources in Azure to handle the additional load (increasing our monthly costs). Last year, it seemed we had hit a wall in terms of any significant progress we could make in providing better quality of service and decreasing costs with the existing framework and libraries. This was the primary motivation for migrating our service to .NET 6.

Our approach

We attempted to keep our initial migration effort simple with a “lift and shift” strategy. We first updated or ported any dependent libraries that were not compatible with .NET 6 (dealing with breaking changes along the way), then we migrated from ASP.NET to ASP.NET Core. Despite trying to minimize the scope of these changes, it was no small amount of work (mostly due to the number of external libraries used in our service). Now that the initial migration is behind us, we’re happy to report that even without additional targeted optimizations, the performance benefits of .NET 6 are quite remarkable! We are also very excited about further improvements on the way in .NET 7.

A note about the results

We did see some CPU and latency improvements following our migration, but the most consistent improvement was a reduction in memory consumption (Process\Private Bytes). As we continue to tune our code base, we are very excited about the more targeted optimizations that this migration unlocks! For example, we can leverage Span<T> to reduce allocations in many more code paths since most BCL APIs now support it as an alternative to byte[]. In addition, we now have access to the multitude of new config options in .NET 6 (https://docs.microsoft.com/en-us/dotnet/core/runtime-config/) and are looking forward to tweaking and tuning the runtime to better suit all our workloads.

The results

The first four processes we migrated are ASP.NET apps that provide a REST APIs using WebAPI. In turn, they each call a REST API for a different upstream dependency (using and HttpClient).

Process 1 (serves static content from Azure Blob Storage):

Percentile Latency (.NET 4.7.2) Latency (.NET 6) +/-
P50 1.8 ms 1.3 ms 28%
P90 3.5 ms 1.6 ms 54%
P99 6.5 ms 2.6 ms 60%

The API was already fast, but on .NET 6, it is much faster! We also saw a reduction in memory consumption:

Private Bytes (.NET 4.7.2) Private Bytes (.NET 6) +/-
725 MB 385 MB 47%

Process 2 (calls the Teams notification service to create posts in Teams channels):

Private Bytes (.NET 4.7.2) Private Bytes (.NET 6) +/-
690 MB 480 MB 30%

Process 3 (calls a NoSQL database to do basic CRUD operations):

Private Bytes (.NET 4.7.2) Private Bytes (.NET 6) +/-
610 MB 205 MB 66%

Process 4 (our highest volume API, which calls a heterogeneous collection of databases):

Private Bytes (.NET 4.7.2) Private Bytes (.NET 6) +/-
2000 MB 1360 MB 32%

The final process I want to highlight is a background worker that receives commands from a message bus (representing updates to several separate data sources) and stores aggregate (denormalized) records in a NoSQL database. This worker handles more than twice as many operations per second as all the other workers in our service backend combined. Here is the CPU utilization chart:

replication-cpu.png

While the variation in the chart makes it hard to state precise figures, it’s pretty clear that CPU utilization dropped at least 25% compared to pre-migration numbers from early April.

Following this migration, we have been able to scale in our compute resources (without affecting overall latency or throughput of the system) and have been able to reduce our monthly compute costs by nearly 37%.

We’ll be making further improvements throughout the coming year, but all in all, .NET 6 has us feeling pretty great about the number of students and teachers we’ll be able to support this fall as the northern hemisphere heads back to school!

The post Microsoft Teams Assignments Service’s Journey to .NET 6 appeared first on .NET Blog.



source https://devblogs.microsoft.com/dotnet/microsoft-teams-assignments-service-dotnet-6-journey/

Comments

Popular posts from this blog

Fake CVR Generator Denmark

What Is Danish CVR The Central Business Register (CVR) is the central register of the state with information on all Danish companies. Since 1999, the Central Business Register has been the authoritative register for current and historical basic data on all registered companies in Denmark. Data comes from the companies' own registrations on Virk Report. There is also information on associations and public authorities in the CVR. As of 2018, CVR also contains information on Greenlandic companies, associations and authorities. In CVR at Virk you can do single lookups, filtered searches, create extracts and subscriptions, and retrieve a wide range of company documents and transcripts. Generate Danish CVR For Test (Fake) Click the button below to generate the valid CVR number for Denmark. You can click multiple times to generate several numbers. These numbers can be used to Test your sofware application that uses CVR, or Testing CVR APIs that Danish Govt provide. Generate

How To Iterate Dictionary Object

Dictionary is a object that can store values in Key-Value pair. its just like a list, the only difference is: List can be iterate using index(0-n) but not the Dictionary . Generally when we try to iterate the dictionary we get below error: " Collection was modified; enumeration operation may not execute. " So How to parse a dictionary and modify its values?? To iterate dictionary we must loop through it's keys or key - value pair. Using keys

How To Append Data to HTML5 localStorage or sessionStorage?

The localStorage property allows you to access a local Storage object. localStorage is similar to sessionStorage. The only difference is that, while data stored in localStorage has no expiration time untill unless user deletes his cache, data stored in sessionStorage gets cleared when the originating window or tab get closed. These are new HTML5 objects and provide these methods to deal with it: The following snippet accesses the current domain's local Storage object and adds a data item to it using Storage.setItem() . localStorage.setItem('myFav', 'Taylor Swift'); or you can use the keyname directly as : localStorage.myFav = 'Taylor Swift'; To grab the value set in localStorage or sessionStorage, we can use localStorage.getItem("myFav"); or localStorage.myFav There's no append function for localStorage or sessionStorage objects. It's not hard to write one though.The simplest solution goes here: But we can kee