VM on Golem Discovery Service - Central hub for provider discovery and resource matching
Project description
VM on Golem Discovery Server
The Discovery Server acts as the central hub of the Golem Network, enabling requestors to find providers with matching resources. It manages provider advertisements, handles resource matching, and ensures system reliability.
System Architecture
graph TB
subgraph Discovery
API[FastAPI Service]
DB[SQLite Database]
Clean[Cleanup Service]
Rate[Rate Limiter]
end
subgraph Providers
P1[Provider 1]
P2[Provider 2]
end
subgraph Requestors
R1[Requestor 1]
R2[Requestor 2]
end
P1 & P2 -->|Advertise| API
R1 & R2 -->|Query| API
API -->|Store/Query| DB
Clean -->|Remove Stale| DB
Rate -->|Protect| API
How It Works
Advertisement Flow
sequenceDiagram
participant P as Provider
participant D as Discovery
participant R as Requestor
P->>D: Advertise Resources
D->>D: Validate & Store
R->>D: Query Resources
D->>D: Match Requirements
D-->>R: Available Providers
Note over D: Auto-cleanup after 5min
The discovery service manages provider advertisements through:
- Resource validation and storage
- Automatic cleanup of stale entries
- Efficient matching of requestor requirements
- Rate limiting and security measures
Installation
# Clone the repository
git clone https://github.com/golem/vm-on-golem.git
cd vm-on-golem/discovery-server
# Install dependencies
poetry install
Configuration
The server can be configured through environment variables:
# Server Settings
DISCOVERY_HOST="0.0.0.0"
DISCOVERY_PORT=7465
DISCOVERY_DEBUG=false
# Rate Limiting
DISCOVERY_RATE_LIMIT_PER_MINUTE=100
# Database
DISCOVERY_DB_URL="sqlite:///discovery.db"
# Cleanup
DISCOVERY_CLEANUP_INTERVAL_SECONDS=60
API Reference
Provider Endpoints
Post Advertisement
POST /api/v1/advertisements
Request:
{
"ip_address": "192.168.1.100",
"country": "SE",
"resources": {
"cpu": 4,
"memory": 8,
"storage": 40
}
}
Required Headers:
X-Provider-ID: Unique provider identifierX-Provider-Signature: Authentication signature
Response:
{
"provider_id": "provider-1",
"ip_address": "192.168.1.100",
"country": "SE",
"resources": {
"cpu": 4,
"memory": 8,
"storage": 40
},
"created_at": "2025-02-20T15:00:00Z",
"updated_at": "2025-02-20T15:00:00Z"
}
Requestor Endpoints
Find Providers
GET /api/v1/advertisements?cpu=2&memory=4&storage=20&country=SE
Response:
[
{
"provider_id": "provider-1",
"ip_address": "192.168.1.100",
"country": "SE",
"resources": {
"cpu": 4,
"memory": 8,
"storage": 40
},
"updated_at": "2025-02-20T15:00:00Z"
}
]
Technical Details
Resource Management
The system tracks three key resources:
- CPU cores (integer)
- Memory in GB (integer)
- Storage in GB (integer)
Resource validation ensures:
- All values are >= 1
- Required fields are present
- Values are within reasonable limits
Advertisement Lifecycle
- Creation: Providers post their available resources
- Update: Providers refresh their advertisement every few minutes
- Expiration: Advertisements older than 5 minutes are automatically removed
- Deletion: Providers can manually remove their advertisement
Security Measures
-
Rate Limiting
- Per-IP rate limiting
- Configurable requests per minute
- Protection against abuse
-
Provider Authentication
- Required provider headers
- Signature verification
- Advertisement ownership validation
-
Input Validation
- Resource requirement validation
- IP address format checking
- Country code validation
Database Schema
CREATE TABLE advertisements (
provider_id TEXT PRIMARY KEY,
ip_address TEXT NOT NULL,
country TEXT NOT NULL,
resources TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
Error Handling
The API uses standardized error responses:
{
"code": "ERROR_CODE",
"message": "Human readable message",
"timestamp": "2025-02-20T15:00:00Z"
}
Common error codes:
AUTH_003: Missing provider credentialsADV_001: Failed to create advertisementADV_002: Invalid resource requirementsRATE_001: Rate limit exceeded
Running the Server
# Start the server
poetry run python run.py
# The server will be available at:
# - API: http://localhost:7465/api/v1
# - Health Check: http://localhost:7465/health
# - OpenAPI Docs: http://localhost:7465/api/v1/openapi.json
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run the tests
- Submit a pull request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file golem_vm_discovery-0.1.1.tar.gz.
File metadata
- Download URL: golem_vm_discovery-0.1.1.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.2 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae2cba34d9466c95aefe933a943abeb6ebc8369b9c3bb8b316ce204f407826bd
|
|
| MD5 |
861eeb1bca786dca6049a83748047d67
|
|
| BLAKE2b-256 |
22a3d4ec250f2bed23440885cdc9ef32a3232980cd2637e4b2a2d4d3fc2d06d1
|
File details
Details for the file golem_vm_discovery-0.1.1-py3-none-any.whl.
File metadata
- Download URL: golem_vm_discovery-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.2 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2d7da4549c9d98bc740eff906fcd0c5ff9baa64d0ef53bfdf998b1f22a6208b
|
|
| MD5 |
3779524e1663d93e3a9d91fe8412dc5d
|
|
| BLAKE2b-256 |
bac25a9fcee0f881e233112384a64828ba06efb5158e9a81b5e22440a257f49a
|