placeholder images
This commit is contained in:
@@ -14,7 +14,7 @@ Your task is to extract the high-throughput ticket purchasing component and exte
|
||||
- `GET /metrics`: Expose real-time metrics (e.g., tickets sold, available tickets per event) in a format compatible with Prometheus.
|
||||
- **Atomic Ticket Purchase:** Implement the purchase logic using a Redis Lua script to atomically verify and pop a ticket from the ticket pool. This ensures no duplicate ticket sales even under massive concurrent access.
|
||||
- **Fallback Mechanism:** If Redis is unavailable or fails during a purchase operation, gracefully fallback to an in-memory store (with appropriate warnings and logs), ensuring the system remains responsive (for demonstration purposes only, as in-memory stores are not persistent).
|
||||
- **Performance and Load Testing:** The service must be designed to handle tens of thousands of requests and be tested under a simulated load of at least 2000 concurrent connections. You should include logging of key performance metrics and purchase statistics.
|
||||
- **Performance and Load Testing:** The service must be designed to handle tens of thousands of requests and be tested under a simulated load of at least 5000 concurrent connections. You should include logging of key performance metrics and purchase statistics.
|
||||
- **Design Documentation:** Provide a detailed design document (`design.md`) that explains your architectural decisions, how you ensure scalability, measures to handle potential bottlenecks, and details on your fallback strategy.
|
||||
- **Dockerization:** Extend the docker-compose setup to include not only Redis but also (optionally) a Prometheus container to scrape and monitor the metrics from your service.
|
||||
- **PDF Ticket Generation:** For every successful ticket purchase, a PDF receipt must be generated. You are free to choose any open-source PDF generation package of your choice (e.g., pdfkit, jsPDF, etc.) to implement this functionality. Ensure that PDF generation is integrated into the purchase flow without significant performance degradation.
|
||||
@@ -26,7 +26,7 @@ Your task is to extract the high-throughput ticket purchasing component and exte
|
||||
3. **Atomic Operations with Lua:** Replace simple atomic operations (like LPOP) with a Redis Lua script that handles the ticket purchase process atomically.
|
||||
4. **Fallback to In-Memory Store:** Implement a fallback mechanism that activates if Redis operations fail, ensuring continued functionality with clear logging that this is a non-persistent backup.
|
||||
5. **Metrics Endpoint:** Provide a `/metrics` endpoint that returns JSON data with real-time statistics (tickets sold, tickets remaining per event, errors, etc.).
|
||||
6. **Robust Testing:** Write comprehensive unit tests and integration tests. The integration tests must simulate high load (>=2000 concurrent requests) and prove that no ticket is sold more than once.
|
||||
6. **Robust Testing:** Write comprehensive unit tests and integration tests. The integration tests must simulate high load (>=5000 concurrent requests) and prove that no ticket is sold more than once.
|
||||
7. **Logging:** Implement detailed logging for purchase operations, errors, and fallback activations.
|
||||
8. **Design Document:** Include a `design.md` file that outlines your architecture, scalability considerations, and design rationale.
|
||||
9. **Docker Support:** Update the docker-compose file to run Redis and optionally Prometheus. Provide clear instructions for running the entire stack.
|
||||
@@ -59,9 +59,9 @@ Your task is to extract the high-throughput ticket purchasing component and exte
|
||||
|
||||
### Load Testing
|
||||
|
||||
Simulate high load using a tool like [autocannon](https://github.com/mcollina/autocannon) or [wrk](https://github.com/wg/wrk). For example, to simulate 2000 concurrent connections on event 1:
|
||||
Simulate high load using a tool like [autocannon](https://github.com/mcollina/autocannon) or [wrk](https://github.com/wg/wrk). For example, to simulate 5000 concurrent connections on event 1:
|
||||
|
||||
npx autocannon -c 2000 -d 30 http://localhost:3049/buy/1
|
||||
npx autocannon -c 5000 -d 30 http://localhost:3049/buy/1
|
||||
|
||||
### Metrics
|
||||
|
||||
|
||||
+13
-27
@@ -2,23 +2,10 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta
|
||||
http-equiv="X-UA-Compatible"
|
||||
content="IE=edge"
|
||||
/>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0"
|
||||
/>
|
||||
<link
|
||||
rel="preconnect"
|
||||
href="https://fonts.googleapis.com"
|
||||
/>
|
||||
<link
|
||||
rel="preconnect"
|
||||
href="https://fonts.gstatic.com"
|
||||
crossorigin
|
||||
/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;500;700;900&display=swap"
|
||||
rel="stylesheet"
|
||||
@@ -28,16 +15,16 @@
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-family: "Roboto", sans-serif;
|
||||
}
|
||||
.ferrari {
|
||||
background-image: url(https://s3.us-west-1.amazonaws.com/com.mkdlab.images/baas/nordin/076532395068ferrari.png);
|
||||
background-image: url(https://placehold.co/600x400/EEE/31343C);
|
||||
background-repeat: no-repeat;
|
||||
background-position: center left;
|
||||
}
|
||||
|
||||
.wing {
|
||||
background-image: url(https://s3.us-west-1.amazonaws.com/com.mkdlab.images/baas/nordin/076532395068wing.png);
|
||||
background-image: url(https://placehold.co/600x400/EEE/31343C);
|
||||
background-repeat: no-repeat;
|
||||
background-position: center right;
|
||||
}
|
||||
@@ -47,7 +34,7 @@
|
||||
<div class="js bg-white grid grid-cols-3 gap-1 bg-[red] p-3"></div>
|
||||
|
||||
<script>
|
||||
const js = document.querySelector(".js")
|
||||
const js = document.querySelector(".js");
|
||||
for (let i = 0; i < 240; i++) {
|
||||
js.innerHTML += ` <div class="border-2 border-black border-dashed relative ">
|
||||
<div class="h-[12px] w-full bg-[#B3E1AB]"></div>
|
||||
@@ -55,12 +42,12 @@
|
||||
<div class="w-[25%] z-[100]">
|
||||
<img
|
||||
class="block w-[96%] h-[50%]"
|
||||
src="https://s3.us-west-1.amazonaws.com/com.mkdlab.images/baas/nordin/076532395068redLottery.png"
|
||||
src="https://placehold.co/600x400/EEE/31343C"
|
||||
alt="lottery car"
|
||||
/>
|
||||
<img
|
||||
class="block w-[98%] h-[50%]"
|
||||
src="https://s3.us-west-1.amazonaws.com/com.mkdlab.images/baas/nordin/076532395068darkLottery.png"
|
||||
src="https://placehold.co/600x400/EEE/31343C"
|
||||
alt="lottery car"
|
||||
/>
|
||||
</div>
|
||||
@@ -101,7 +88,7 @@
|
||||
</h5>
|
||||
|
||||
<img
|
||||
src="https://s3.us-west-1.amazonaws.com/com.mkdlab.images/baas/nordin/076532395068appLogo.svg"
|
||||
src="https://placehold.co/600x400/EEE/31343C"
|
||||
class="h-[35px]"
|
||||
alt=""
|
||||
/>
|
||||
@@ -114,13 +101,12 @@
|
||||
</div>
|
||||
<div class="h-[12px] w-full bg-[#B3E1AB]"></div>
|
||||
<img
|
||||
src="https://s3.us-west-1.amazonaws.com/com.mkdlab.images/baas/nordin/076532395068barcode.png"
|
||||
src=https://placehold.co/600x400/EEE/31343C"
|
||||
alt="barcode"
|
||||
class="absolute top-1/2 right-0 transform -translate-y-1/2"
|
||||
/>
|
||||
</div>
|
||||
`
|
||||
|
||||
`;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user