A RESTful web service enabling sustainable item rental through a sharing economy platform. Users can browse items, calculate distances, apply filters, and manage rental requests.
Student ID: N1237155
Module: COMP30231 Service-Centric and Cloud Computing
University: Nottingham Trent University
http://localhost:8080/RESTServices/
http://{Your VM IP}:8080/RESTServices/
Important: Replace {Your VM IP} with your Azure VM's public IP address (e.g., 4.251.106.173). You can find this in the Azure Portal under your VM's Overview page.
Both URLs provide interactive API documentation with click-to-copy endpoints. Remember to also update the {Your VM IP} placeholder in RESTServices/web/index.html with your actual VM IP address.
Built a fully functional RESTful API with JAX-RS that handles:
- Item retrieval with filtering (category, city, condition)
- Pagination (5 items per page)
- Rental request creation and cancellation
- JSON serialization/deserialization using Jackson
- Connection pooling for Azure Cosmos DB
Integrated OSRM routing API for real-time distance and duration calculations:
- Direct coordinate-to-coordinate distance
- User-to-item distance calculation
- Comprehensive error handling for external service failures
- Singleton HttpClient for connection pooling
Conducted systematic JMeter load testing and implemented two critical performance improvements.
Git Tag: pre-qos baseline marks the codebase before performance improvements were applied.
Bottleneck 1: Cosmos DB Connection Exhaustion
- Issue: Creating new database connections per request caused system failure at 200 concurrent users
- Solution: Singleton pattern with connection pooling
- Result: 99.7% latency reduction, 0% error rate at 1000+ users
Bottleneck 2: HTTP Client Resource Exhaustion
- Issue: New HttpClient per OSRM call caused 50% failure rate under load
- Solution: Shared HttpClient with automatic connection reuse
- Result: 99.89% faster responses (111s → 0.1s), 0% errors at 1000 users
Testing evidence and detailed analysis available in /Testing Evidence/ directory.
Successfully deployed to Azure with:
- Ubuntu 22.04 VM (Standard B2s)
- Apache Tomcat 9 with Java 17
- Azure Cosmos DB for NoSQL storage
- Public accessibility via HTTP port 8080
See DEPLOYMENT_README.md for complete deployment documentation.
Frontend: HTML5 API documentation page (dark theme) Backend: JAX-RS REST services Database: Azure Cosmos DB (NoSQL) External APIs: OSRM (routing) Server: Apache Tomcat 9 Runtime: Java 17
Before running the application, you must create an Azure Cosmos DB account and configure the connection.
- Go to Azure Portal
- Search for "Azure Cosmos DB" and click "Create"
- Select Azure Cosmos DB for NoSQL
- Configure:
- Subscription: Your Azure subscription
- Resource Group: Create new or use existing
- Account Name: Choose a unique name
- Location: Choose a region close to your VM
- Capacity mode: Serverless (for development) or Provisioned throughput
After the account is created:
- Go to your Cosmos DB account → Data Explorer
- Click New Database and create a database named:
Coursework - Create two containers:
- Container 1:
itemswith partition key/item_id - Container 2:
Requestswith partition key/item_id
- Container 1:
- Go to your Cosmos DB account → Keys (under Settings)
- Copy the following values:
- URI (Endpoint):
https://your-account-name.documents.azure.com:443/ - PRIMARY KEY: Your secret key
- URI (Endpoint):
Open src/java/RESTAPI/CosmosDBConnection.java and update:
private static final String ENDPOINT = "https://your-account-name.documents.azure.com:443/";
private static final String KEY = "your-primary-key-here";Security Note: For production, store credentials in environment variables instead of hardcoding them.
Distance Calculation
http://localhost:8080/RESTServices/webresources/RESTAPI/direct?startLon=-0.1276&startLat=51.5074&endLon=-2.2426&endLat=53.4808
Get All Items
http://localhost:8080/RESTServices/webresources/RESTAPI/items
Get Items with Distance
http://localhost:8080/RESTServices/webresources/RESTAPI/items?userLat=51.5074&userLon=-0.1276
Pagination
http://localhost:8080/RESTServices/webresources/RESTAPI/items?page=1
Filtering (multiple filters supported)
http://localhost:8080/RESTServices/webresources/RESTAPI/items?category=Tools&city=London&condition=Excellent
Request Item
curl -X POST "http://localhost:8080/RESTServices/webresources/RESTAPI/items/i001/request?user_id=Alice"Cancel Request
curl -X PUT "http://localhost:8080/RESTServices/webresources/RESTAPI/requests/REQ-{request_id}/cancel"Replace localhost:8080 with {Your VM IP}:8080 in any of the above URLs.
Example:
http://{Your VM IP}:8080/RESTServices/webresources/RESTAPI/items
├── src/RESTAPI/ # Java source files
│ ├── RESTServices.java # Main REST endpoints
│ ├── CosmosDBConnection.java # Database connection (singleton)
│ ├── items.java # Item data model
│ ├── Request.java # Request data model
│ └── [other models] # Response models
├── web/
│ ├── index.html # API documentation page
│ └── WEB-INF/lib/ # JAR dependencies
├── Testing Evidence/ # JMeter tests & QoS analysis
│ ├── Bottle Necks/ # Performance issue documentation
│ ├── Part C - QoS Testing/ # Load testing results
│ └── Part D - Cloud Deployment/ # Deployment screenshots
├── DEPLOYMENT_README.md # Detailed deployment guide
└── README.md # This file
- Java 17 - Runtime environment
- JAX-RS - RESTful web services
- Jackson - JSON processing
- Azure Cosmos DB SDK - NoSQL database client
- Apache Tomcat 9 - Application server
- OSRM API - Distance/routing calculations
- JMeter - Load testing and QoS analysis
✅ RESTful API following REST principles
✅ Cloud-deployed with public accessibility
✅ Real-time distance calculations via OSRM
✅ Advanced filtering and pagination
✅ Performance-optimized with connection pooling
✅ Comprehensive error handling
✅ Load-tested up to 1000+ concurrent users
✅ Interactive API documentation
After Optimization:
- Average response time: ~100ms
- Throughput: 99 requests/sec
- Error rate: 0% (at 1000 concurrent users)
- Database connection overhead: Eliminated
- External API call efficiency: 1000× improvement
© 2026 | Developed for COMP30231 Service-Centric and Cloud Computing | Nottingham Trent University