Amazon Interview Question






Comment hidden because of low score. Click to expand.
1
of 1 vote

For the database part:

This seems more like db tuning excercise, but I might first check that if I can do all the 5 calls to db in a single connection instead opening and closing db connection everytime I need it. This will reduce the time way below 35 seconds.

If possible materialized views can also be of some help.

- WHIZKID November 28, 2005 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Needless to say that 5 Reads should use only one single connection. If the database server runs on a single cpu box, it will still takes 35 seconds. So the result should be cached if the data do not change that often. Two levels of caching can be used. They are in memory and on disk. Well it becomes very complicated if it is in a clustered enviroment and cache coherence is a must.

- Firfox March 03, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Several ways to improve performance...

No connectors are specified, so no assumption can be made about the type of connection(s).

1) DB indexing on most frequent tables(tuning)
2) Cache results on app server
3) Cache results on web server
4) Cache results on user-machine(if small, use cookies).
5) Use AJAX for asynchronous loading

- Jack December 02, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Needless to say that 5 Reads should use only one single connection. If the database server runs on a single cpu box, it will still takes 35 seconds. So the result should be cached if the data do not change that often. Two levels of caching can be used. They are in memory and on disk. Well it becomes very complicated if it is in a clustered enviroment and cache coherence is a must.

- Firfox March 03, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Since nobody will wait 35 seconds for a webpage to load, you might want to have the page callback to the server and request each item individually while the page is loading.

- Juice December 01, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

caching can always help

use connection pool.
which will solve the problem in way below than 35 seconds

- ashish July 03, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Optimize the database reads and reduce the time from 7 secs to lesser
2. Do lazy reading where by you read only the minimum amount of data and so reduce the number of database reads.
3. Denormalize your data and so that you dont do multiple joins
4. Build a cache and load the data eagerly.
5. Use AJAX like mechanism to load in the background what is not critical.
6. Use Materialized Views

- Vs June 19, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Need clarification on these 'reads' :

- These reads are basically sql queries ? (JDBC statements)
- are these reads related ?
- is each read by itself optimized ? .. as in 7 sec is unavoidable ? or query to be tuned



Two levels of tuning :

1. See if each read can be optimized independently . SQL tuning check explain plan, total cost,FTS, buffer gets etc. Also does each read leak any connection object
Can there be caching to cater for each read

2. Can reads be combined to avoid multiple calls. This has a trade off. If each read gets lot of data in memory, combining may cause memory hog. Otherwise better to combine

- Anonymous April 16, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Need clarification on these 'reads' :

1 These reads are basically sql queries ? (JDBC statements)
2 are these reads related ?
3 is each read by itself optimized ? .. as in 7 sec is unavoidable ? or query to be tuned



Two levels of tuning :

1. See if each read can be optimized independently . SQL tuning check explain plan, total cost,FTS, buffer gets etc. Also does each read leak any connection object
Can there be caching to cater for each read

2. Can reads be combined to avoid multiple calls. This has a trade off. If each read gets lot of data in memory, combining may cause memory hog. Otherwise better to combine

- Anonymous April 16, 2018 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More