You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #27 from cristofima/dev - perf: implement ETag-based caching and job details handling improvements
- ETag-based conditional requests with 304 Not Modified responses for job details
- In-memory caching of S3 presigned URLs with 80% TTL to reduce API calls
- Frontend utility to preserve valid presigned URLs when merging job state updates
Copy file name to clipboardExpand all lines: backend/README.md
+31-2Lines changed: 31 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -263,6 +263,14 @@ Or mount `~/.aws` when using Docker (already configured in docker-compose.yml).
263
263
264
264
4.**CORS Errors**: The API includes CORS middleware. Check `api/main.py` if issues persist.
265
265
266
+
### Caching Strategy
267
+
268
+
The API implements strict caching controls to ensure UI consistency:
269
+
270
+
-**GET /jobs/{id}**: `Cache-Control: private, max-age=0, must-revalidate`. Forces browsers to validate ETag on every request, ensuring deployment status changes are seen immediately. Uses DynamoDB Strong Consistency (`ConsistentRead=True`) to generate accurate ETags.
-**Consistency**: Critical operations (`update_job_metadata`, `deploy_model`) use DynamoDB Strong Consistency (`ConsistentRead=True`) to guarantee read-after-write accuracy.
273
+
266
274
## 🧪 Testing
267
275
268
276
The backend includes comprehensive unit and integration tests for both API and Training modules. Tests run automatically in CI/CD pipelines before deployment.
@@ -272,14 +280,14 @@ The backend includes comprehensive unit and integration tests for both API and T
└── training/ # Training tests (159 tests, 53% coverage)
290
+
└── training/ # Training tests (159 tests, 63% coverage)
283
291
├── conftest.py # Shared fixtures
284
292
├── unit/ # Pure unit tests
285
293
│ ├── test_preprocessor.py
@@ -387,3 +395,24 @@ from training.utils.detection import (
387
395
This follows the DRY principle - logic is defined once and reused across `core/preprocessor.py` and `reports/eda.py`.
388
396
389
397
This detection is performed both in the API (for UI display) and in the training container (for model training).
398
+
399
+
## 💰 Cost Analysis (Inference)
400
+
401
+
Based on official [AWS SageMaker Pricing](https://aws.amazon.com/sagemaker/ai/pricing/) and [Lambda Pricing](https://aws.amazon.com/lambda/pricing/) for `us-east-1`:
|**Per Prediction**|~$0.000004 | Included | Included |
408
+
|**Break-even**|**Best for < 9M reqs**| Better for 9M-40M reqs | Better for > 42M reqs |
409
+
410
+
### Real-world Scenario (100k predictions/mo)
411
+
-**Serverless**: **$0.40** (Virtually free)
412
+
-**SageMaker (t3.medium)**: $36.00 (Fixed cost)
413
+
-**Savings**: **98.8%** cost reduction for low-to-moderate workloads.
414
+
415
+
> [!TIP]
416
+
> This project is designed to be **"Side Project Friendly"**. By using Serverless Inference, you avoid the $432-$2,056 yearly cost of keeping a SageMaker endpoint running 24/7.
0 commit comments