Amazon Interview Question
Software Engineer / DevelopersCountry: India
Interview Type: In-Person
This is a very generic question and thrown to check the Web development skills.
The answer at high level would include:
1. Enabling gzip compression for the responses.
2. enabling caching for the static content. e.g. images, headers, logos, CSSs, js
3. Paginating the the large resultsets
These are at very high level without considering the scalability, high availability. Those aspects open different chapters altogether.
First you have to profile the website, then find the bottleneck and try to fix it. It may be a DB indexing problem or something else.
IMO, we need to understand what Optimize means. For example, at a very high level, it could mean one of the following
+ Optimize Functionality
++ Better placement of frames
++ Better relational logic
+ Optimize Performance
++ Faster loading of pages
++ Better readahead of related pages
++ More simultaneous operations.
+ Optimize Quality
++ no plugin crashes, etc etc
+ Optimize Security
++ .....
0. Profile the site using Chrome dev tools and check the Audits panel
1. Cache static resources to reduce HTTP requests
2. Minify/Merge JS and CSS files to reduce file size and bandwidth
3. Use CDN to increase the number of files simultaneously downloaded
4. Use Redis to reduce DB accesses
5. Buy a more powerful server
6. Cache jQuery objects when possible
7. Put <script> tags at the bottom of the HTML
8. Prevent to much DOM manipulation
9. Use varnish or nginx reverse proxy
10. Enable gzip compression in the server
11. Use Connection: keep-alive header in order to reuse existing TCP connection and prevent additional TCP handshakes
12. Use SVG sprite instead of separate images for icons to reduce HTTP requests
13. Remove unused scripts and CSS styles
developer.yahoo.com list for performance
- vgokulraj March 14, 2014Make Fewer HTTP Requests
Use a Content Delivery Network (CDN)
Add Expires or Cache-Control Header
Gzip Components
Put Stylesheets at Top
Put Scripts at Bottom
Avoid CSS Expressions
Make JavaScript and CSS External
Reduce DNS Lookups
Minify JavaScript and CSS
Avoid Redirects
Remove Duplicate Scripts
Configure ETags
Make Ajax Cacheable
Flush Buffer Early
Use GET for Ajax Requests
Postload Components
Preload Components
Reduce the Number of DOM Elements
Split Components Across Domains
Minimize Number of iframes
Avoid 404s
Reduce Cookie Size
Use Cookie-Free Domains for Components
Minimize DOM Access
Develop Smart Event Handlers
Choose <link> Over @import
Avoid Filters
Optimize Images
Optimize CSS Sprites
Do Not Scale Images in HTML
Make favicon.ico Small and Cacheable
Keep Components Under 25 KB
Pack Components Into a Multipart Document
Avoid Empty Image src
developer.yahoo.com/performance/rules.html