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.
|
- `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.
|
- **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).
|
- **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.
|
- **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.
|
- **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.
|
- **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.
|
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.
|
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.).
|
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.
|
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.
|
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.
|
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
|
### 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
|
### Metrics
|
||||||
|
|
||||||
|
|||||||
+22
-36
@@ -2,23 +2,10 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
http-equiv="X-UA-Compatible"
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
content="IE=edge"
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
/>
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
<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
|
<link
|
||||||
href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;500;700;900&display=swap"
|
href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;500;700;900&display=swap"
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
@@ -28,39 +15,39 @@
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
font-family: 'Roboto', sans-serif;
|
font-family: "Roboto", sans-serif;
|
||||||
}
|
}
|
||||||
.ferrari {
|
.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-repeat: no-repeat;
|
||||||
background-position: center left;
|
background-position: center left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wing {
|
.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-repeat: no-repeat;
|
||||||
background-position: center right;
|
background-position: center right;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body class="h-screen w-screen h-[800px] overflow-x-hidden ">
|
<body class="h-screen w-screen h-[800px] overflow-x-hidden">
|
||||||
<div class=" js bg-white grid grid-cols-3 gap-1 bg-[red] p-3 "></div>
|
<div class="js bg-white grid grid-cols-3 gap-1 bg-[red] p-3"></div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const js = document.querySelector(".js")
|
const js = document.querySelector(".js");
|
||||||
for(let i = 0 ; i < 240; i++) {
|
for (let i = 0; i < 240; i++) {
|
||||||
js.innerHTML += ` <div class="border-2 border-black border-dashed relative ">
|
js.innerHTML += ` <div class="border-2 border-black border-dashed relative ">
|
||||||
<div class="h-[12px] w-full bg-[#B3E1AB]"></div>
|
<div class="h-[12px] w-full bg-[#B3E1AB]"></div>
|
||||||
<div class="flex h-[245px] bg-[#EDF0F3] w-[100%] ">
|
<div class="flex h-[245px] bg-[#EDF0F3] w-[100%] ">
|
||||||
<div class="w-[25%] z-[100]">
|
<div class="w-[25%] z-[100]">
|
||||||
<img
|
<img
|
||||||
class="block w-[96%] h-[50%]"
|
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"
|
alt="lottery car"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
class="block w-[98%] h-[50%]"
|
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"
|
alt="lottery car"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -101,7 +88,7 @@
|
|||||||
</h5>
|
</h5>
|
||||||
|
|
||||||
<img
|
<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]"
|
class="h-[35px]"
|
||||||
alt=""
|
alt=""
|
||||||
/>
|
/>
|
||||||
@@ -114,14 +101,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="h-[12px] w-full bg-[#B3E1AB]"></div>
|
<div class="h-[12px] w-full bg-[#B3E1AB]"></div>
|
||||||
<img
|
<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"
|
alt="barcode"
|
||||||
class="absolute top-1/2 right-0 transform -translate-y-1/2"
|
class="absolute top-1/2 right-0 transform -translate-y-1/2"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
`
|
`;
|
||||||
|
}
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user