Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Azure Socket Leaks?!

$
0
0

I have an ASP.NET Core a website with a lot of simultaneous users which crashes many times during the day and I scaled up and out but no luck.
I have been told my numerous Azure support staff that the issue is that I'm sending out a lot of database calls although database utilization improved after creating indexes. Can you kindly advice what you think the problem is as I have did my best... I have 2 instances running and using a very expensive tier!
I was told that I have "socket leaks".

Please note:

- I don't have any external service calls except to sendgrid
- I have not used ConfigureAwait(false)

- I'm not using "using" statments or explicitly disposing contexts

This is my connection string If it may help...

Server=tcp:sarahah.database.windows.net,1433;Initial Catalog=SarahahDb;Persist Security Info=False;User ID=********;Password=******;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Max Pool Size=400;

These are some code examples:

In Startup.CS:

services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

Main class:

private readonly ApplicationDbContext _context;

public MessagesController(ApplicationDbContext context, IEmailSender emailSender, UserManager<ApplicationUser> userManager)
{
_context = context;
_emailSender = emailSender;
_userManager = userManager;
}

This an important method code for example:

string UserId = _userManager.GetUserId(User);
var user = await _context.Users.Where(u => u.Id.Equals(UserId)).Include(u => u.Messages).FirstOrDefaultAsync();
// some other code
return View(user.Messages);

Please advice as I have tried my best but this is very embarrassing to me in font of my customers.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>