ASP.NET, MVC, Entity Framework website slow TTFB - performance

I've created a website that hosted in IIS on a server local to my company, it will only be used by employees of the business. I've been using Chrome dev tools to monitor the network activity and see loading times etc. I've noticed that my TTFB is always really slow, even when I'm loading very little data.
I read an article earlier that stated the TTFB should ideally be less than 500ms, yet mine is routinely over 3 or 4 seconds atleast!
I've included a screenshot of the dev tool page showing what I mean:
The particular page I've loaded is the home page. It connects to an MSSQL DB using EF6 and does one query to check if a person exists in a table with about 200 entries. Here is the code:
using (var db = new DbContext())
{
var ad = httpContext.User.Identity.GetActiveDirectory();
var person = db.PERSON.Include(p => p.PERSON_PRIVILEGE_ALLOC).FirstOrDefault(p => p.ACTIVE_DIRECTORY == ad);
}
If I load this same page on my machine using IIS Express the TTFB for the html doc is 35ms. Compared to a TTFB of 3450ms when loaded on our main server.
This is my first proper website to be hosted and so I'm relatively new to this. I understand what TTFB is but I'm unsure what is taking so long? The Db query is small and quick, the html isn't over sized, the CCS and JS is about 1MB when compressed using GZIP.
Does anyone have any info or suggestions to what is causing this and how it could be sped up? Could it potentially just be caused by the server?

It seems to be a problem with the server or server configuration.
Maybe the connection to Active Directory or database takes a long time.
You could diagnose performance issues with the Stopwatch class.
Start the stopwatch before the call to AD and log the elapsed time when the call returns. Start a second stopwatch for the database query and log the result too.

Related

Sorlbridge/Solr is very slow for 300k products

I installed solrbridge on my website and I have a problem with performance. Everything was ok for 10k products. but after upload 320k product request to solr takes 55-70s. I noticed this happens only for the first request.
for example this url:
sample_local_url (now working, please inspect to check params)
takes 56[s] for the first time, and after it takes 50-60[ms] (even in different web browser so this cannot be local web browser cache)
And this is happening with all requests. I understand there is some kind of cache in solr. I wonder if this is possible to increase the performance of this.

Optimising Magento Loading Speed - Can't Identify Why Initial Recieving So Slow

While our website is not yet complete graphically and design wise, most of the backend operations are near completion.
However, after optimising the mysql database we are still receiving a significant initial receiving period when tested on pingdom.com:
http://tools.pingdom.com/fpt/#!/IuoBna86v/http://foscam-uk.com
According to Pingdom:
The yellow part is the time it takes to resolve the hostname and similar (before the connection is initiated to the web server), the green part is connecting to the web server, and the blue part is the time it takes to retrieve the content from the webserver.
Upon asking our managed VPS support team we got the response : 'Have you tried optimizing your script? I believe that the high wait time on there indicates actual website loading time (meaning for your script to load); not actual connection to the website/server.'
Now, pingdom shows the js/css loading relatively quickly, the mysql database side of things doesn't seem to be slowing anything down either - does anyone have any suggestions of what this could be or might be causing it?
Thank you very much for your time and help.
89 requests are too many.
Reduce number of image request by creating sprites.This is pretty important from what is shown in pingdom.
Keep Alive should be set to On and Keep alive time should be a bit higher(15 seconds or so).
Use of compiler plus merge and minify js/css is recommended.
Change the hosting provider. 8 second loading is very very slow. It means that it actually is around 15-17 seconds for a user that doesn't have cached parts of your site (first time visitor). My site www.bebepunk.ro loads according to pingdom in 2.5 seconds and users still complain about the slowness of the site. Check also with http://www.webpagetest.org for both values.

Reloading HttpRuntime.Cache asychronously

I have asp net website with a very slow query on a remote database. To address that problem I use caching in Application_Start.
HttpRuntime.Cache["Folders"] = (from f in db.Folders select f).ToList();
in the controller
var folderList = (List<Folder>)HttpRuntime.Cache["Folders"];
It takes quite an amount of time to load the website the first time but when it's up it's fast. I also use the new serverAutoStart="true" feature of IIS so the website is always running with the Cache loaded. Even if the application pool restart IIS will load the website in a new W3wp process and switch the processes when the new instance is loaded. Resulting in no downtime or slow starting up.
But now I would like to reload the cache when some controller action occurs. So is it possible to reload it asynchronously without blocking all the website or the session that triggered the action while reloading it ? Also I would like that the current Cache["Folders"] still works during the operation.
You can make use of Parallel Tasks
var repopulateCache = new System.Action(() => RepopulateCache(someParameter);
Task.Factory.StartNew(repopulateCache);
It is recommended to know what you are doing before using this, try reading some background information.
That said, I've had this in production for a while and it works very well and means you don't have to worry (too much) about the usual perils of threading. It willl create background work on your web server but in your case it doesn't sound like a big risk.

Long delay getting data from a server for one site but not 2 others

We're running 3 different Drupal (Pressflow to be specific) sites on the same server. The 2nd and 3rd sites were cloned from the first one and load just fine. The first one, though, is taking a few seconds to connect and start sending data back from the server. Same box, same config (as far as we know), same modules, and generally the same theme. Here's what Pingdom shows...
Fast site:
http://i.stack.imgur.com/YZilC.png
Slow site:
http://i.stack.imgur.com/6Um1M.png
Edit: Those are from Pingdom, the yellow indicating "The web browser is waiting for data from the server"
The configs are the same, performance options same, server configs, as far as we can tell are the same. The delay occurs before any page elements are visible so it's not an on-page object problem or a page speed problem.
Could this be a config issue with the server? Where should we be investigating?
Thanks in advance!
I would try increasing the size of your MySQL cache. It's possible the fast sites have their particular queries cached and the slow site has a query that doesn't quite fit the cache, so the MySQL query results need to be regenerated each time.
Just a guess!

SSRS Performance when first opening Browser

I have a set of reports using SSRS on a dedicated Reports server. Our reports are launched via hyper links on an aspx page. The hyper links open a report (in a new broswer) with selectable paramaters. There is no data when the reports initially load. However, the first time loading a report in the browser takes a significant amount of time. 30 - 50 seconds. Subsequent loading of any of the reports is much faster. It seemes like the server is spinning up objects in the background during the initial load.
Does anyone know the cause of this initial load performace issue?
Thanks
SSRS is just another ASP.NET app (see below) that works within the standard IIS environment.
Schedule a report email every 15 minutes to keep it loaded or change IIS settings.
SSRS comprises (from an App perspective):
A service that deals with schedules, sessions etc
ReportManager web site that looks like the main entry point to SSRS
ReportServer web service that does the work, rendering, reporz access etc
You're seeing the double whammy of ReportManager + ReportServer IIS timeouts. Scheduling will only remove the ReportServer timeout.
It's exactly what you suspect, Mike - the web server is loading all the required bits'n'pieces. You get the same delay if you try to browse to the SSRS management pages 'the first time' in a day. Once someone has opened a report, or viewed the management pages, the delay goes away.
Two things off the top of my head:
Did you test to see how long the query/sproc would execute when developing the report?
How much data are you trying to pull over? Is your data being sorted?
If you're using a query, you may want to consider using a stored procedure

Resources