00 - Assignment
The Task
Description
Write an HTTP server. You can choose to implement it either in Python or Go. The server should serve one endpoint:
/api/smart
Requirements for the endpoint:
- The endpoint performs up to 3 HTTP requests to the Exponea Testing HTTP Server and returns the first successful response.
- Instead of firing all 3 requests at once, the endpoint fires only a single request at the
beginning.
- If there is a successful response within 300 milliseconds, the endpoint returns this response and does not fire other requests.
- If there is no successful response within 300 milliseconds, it fires another 2 requests. Then it returns the first successful response from any of the 3 requests (including the first one).
- The endpoint accepts a timeout parameter - an integer value specifying time in milliseconds. The endpoint always returns a response within the given timeout. If the timeout is not specified, the endpoint should respond with the first successful response from our testing server.
- If there is no successful response within this timeout, the endpoint returns an error.
Notes
- The endpoint returns a JSON response.
- A successful response is defined as a response that returns HTTP status code 200 and has a valid payload.
- Your endpoints should return a JSON response that will contain successful responses from Bloomreach testing server.
Bloomreach Testing HTTP Server
The Bloomreach Testing HTTP Server serves a single endpoint:
GET https://exponea-engineering-assignment.appspot.com/api/work
It performs some work (taking roughly 100-600 ms) and then returns the time it took to
respond as a JSON response. Example response:
{“time”: 160}
Note: The server is not very reliable , which means that it does not always return a successful response.
What we seek
- Performance - we expect that the requests to ExponeaTesting HTTP Server will be done concurrently. We will test how your server implementation behaves under load - both in terms of requests per second, and the number of concurrent requests.
- Robust implementation - your server should behave correctly in presence of errors. Exponea Testing HTTP Server is infamously known for being unreliable. Also, the implementation should not leak resources (stuck threads / goroutines / connections for unknown time).
- Readable, maintainable implementation - for example, prefer well-known open source libraries, with licenses that allow them to be used commercially.
If you want to shine…
Is the task too easy for you? Don’t worry, we have prepared a few extras for you:
- Write tests for your implementation.
- Instrument your code with tools that will make debugging production easier - logging, monitoring, tracing. We need a way to check if Bloomreach Testing HTTP Server is behaving well in production.
- Include Dockerfile that can be used to build and run the server.
- Attach a discussion about code behavior - knowledge cases, how it behaves in certain conditions, performance characteristics, resource requirements, etc. How many concurrent requests can the server handle? How would you protect the server against being overloaded?