Pergunta de entrevista da empresa CarGurus

how to debug if a page is taking time in production

Resposta da entrevista

Sigiloso

13 de dez. de 2019

This is how I responded. 1 - Load the page and see what's happening on DB side ( by Profiler). 2 - Check if there is any SP which is taking long time. 3 - if there is any SP which is taking unexpected time than look into SP to optimize it, best way as how I do it to find out which query is causing issue and than try to see what's wrong with it, and there can be multiple issue, might be query is not written properly at all, joins are not being used properly, you are not using Indexed column in query, you may be using Inner query, you may be using temp table and applying indexes may needed for temp tables, may be you are querying large table and using multiple joins, and possibly using temp table to first filter data and than use it afterwards can help it, simply saying you need to identify the issue and resolve it in best manner ( Remember when you are working with production, you have to resolve issue in limited time, and you may chose to resolve it in a way which may not be the best solution to problem but is the best solution at that time), anyways in nutshell you find out issue and fix it in best possible way as per situation. 4 - If you don't find any issue on SP side than it means there is issue with application, and than you have to figure it out that what is causing this issue? it could be bad code written in back-end or it could be issue with your client side scripting (JS if it's taking time to load), so we have to figure out what is bottleneck and need to resolve it in best manner. the example I gave him with search and paging, i.e. if your search is bringing 100,000 than one option is to limit the result set coming from Database as in real world no one goes to more than 10-20 pages at max ( I know someone would say that person can go to page 60 directly and that's true) but you are in production and you have to do what is best to resolve problem immediately, you can limit the records and save time for 90% of people and ask people to make search narrow (you can simple display message on UI with UI change that search will bring only first 10,000 records so people will know), again this is not the only solution for issue, it all depend upon problem and situation, might be you are in situation to fix issue and deploy app in 10 minutes, so solution is to find out the problem and come up with solution to fix it (you can do immediate fix and than proper fix later one based on situation). This is what I explained based on my experience, remember I didn't touch issues related to server performance, possible locks or any other processors running in parallel and contributing to issue or communication issues between severs or any issue related to infrastructure assuming that we are not discussing these point. for me this is very open ended question and to answer which satisfy depends upon who is interviewing you and what level of approach or thinking he / she may have