Google Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
6
of 8 vote

This is about creating a Singlenton class that holds a cache of connections so that the connections can be reused when future requests to the database are required.

When you say that "When the user is done, returns them back to the pool" means that you just freed one of your N connection hold in your cache, wich means It can be use by another user/request/process/thread/etc

There is a creational design pattern called object pool pattern if you want to get into details.

Additionally, there are a lot open source software that are in charged of such task. In real life, It is hard that someones needs to rebuild the wheel, but It is a good idea to knoew in details such open source software to disscuss it during the interview and why not came up with your own implentation.

hope It works.

cheers

- .·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º> January 20, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
1
of 1 vote

This is semaphore problem. Let say you have 20 connection pools, you will allow 20 threads to get the pool, and wait if there are more requests coming in. Until one of them returns it to the pool then the waiting thread can get it.

- dawong January 22, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A. Keep a maxCount that depends on the underlying implementation of the resource availability such as max allowed connections in an RDBMS.
B. Keep a currentCount that needs to be synchronized across threads when incrementing/decrementing
C. Keep a timeOut in case, connection is not released
D. Keep a Queue for waiting clients in case pool is full, must be synchronized as well for multi-threading
E. High level methods: getConnection, releaseConnection, forceTimeout, Queue operations such as push, pop etc.

- mo February 08, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

For others, a 'connection pool' is for databases, not web connections (at least, the DB version was what came up first on Google). I had a hard time imagining how web-connections could be reused.

- JeffD February 17, 2014 | 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