zpe0lw
Last Updated: February 25, 2016
·
969
· 20after4
D1b4ad74e9dd45c2837df1f435bbfd52

Optimizing a website performance

While filling out a job application I was asked to answer this question:

What are some of the ways you can improve the performance of a web application you’ve written?

Here is my somewhat long-winded answer:

There are different aspects to the performance of a website that could be optimized.

Server-side performance optimization


Some of the most common performance issues in the typical web application are caused by poorly optimized database queries. So the first place I would look for potential optimization is sql query times. Tracing the query execution time should reveal any problematic queries. The best place to start is with the slowest, of course, but any query that runs for longer than about 20 milliseconds may have room for improvement.

Once slow queries are identified I would attempt to improve query performance by adjusting table indexes or adjusting queries so that they utilize an available index. With mysql the rule of thumb is that queries should always include a where clause that begins with a column which is either indexed alone or that forms the first part of a multipart index.

Client-side performance optimization


I would start with optimizing scripts and style sheets. JS and CSS can be combined into fewer large files instead of numerous tiny files. This eliminates http connection overhead. Additionally script minification and/or compression can reduce the file size and static optimizations can improve the execution time of client side scripts.

A similar optimization can be applied when there are several small graphical elements on a page. These images can be combined into a single file which is known as a "sprite sheet." The benefit is that fewer http connections are needed to load a complete web page. The drawback is increased complexity of css code which is needed to utilize the sprites and the considerable effort involved with converting the existing code.

Say Thanks
Respond

2 Responses
Add your response

4689
D42a7264714dee5006b9c99d2567a320

The fastest query is no query at all :)
Make as many things static as you can + care about proper caching (again, this is both on client and server side).

over 1 year ago ·
11852
D42a7264714dee5006b9c99d2567a320

I organized the best practices for page load performance into a mindmap, see my tip:
https://coderwall.com/p/jhnuza

over 1 year ago ·