No description
  • Python 76.5%
  • HCL 18.9%
  • Makefile 4.6%
Find a file
2026-01-20 21:16:48 +01:00
terraform initial commit 2026-01-20 21:16:48 +01:00
.gitignore initial commit 2026-01-20 21:16:48 +01:00
check_latency.py initial commit 2026-01-20 21:16:48 +01:00
invoke_and_report.py initial commit 2026-01-20 21:16:48 +01:00
Makefile initial commit 2026-01-20 21:16:48 +01:00
README.md initial commit 2026-01-20 21:16:48 +01:00
requirements.txt initial commit 2026-01-20 21:16:48 +01:00

Polymarket Latency Checker

A tool to measure real-time latency between Polymarket's CLOB WebSocket and various AWS regions (US, EU, Spain, and Tokyo).

Architecture

  1. Lambda Layer: A Python script (check_latency.py) that connects to Polymarket's ws-subscriptions-clob WebSocket, subscribes to an active market, and calculates the difference between the server's message timestamp and the local arrival time for 30 seconds.
  2. Infrastructure: Managed with Terraform 6.0, deploying the same Lambda function to 6 global regions using for_each.
  3. Runner: A local Python script (invoke_and_report.py) that triggers all Lambdas concurrently and generates a comparative report.

Regions Included

  • us-east-1 (N. Virginia)
  • us-west-2 (Oregon)
  • eu-west-1 (Ireland)
  • eu-central-1 (Frankfurt)
  • eu-south-2 (Spain - Madrid)
  • ap-northeast-1 (Tokyo)
  • eu-west-2 (London)

Prerequisites

  • uv (Fast Python package manager)
  • Terraform (>= 1.0)
  • AWS CLI configured with appropriate credentials.

Usage

1. Deploy Infrastructure

This will package the Python dependencies, initialize Terraform, and deploy the Lambdas to all regions.

make deploy

2. Run Latency Test

This will invoke all Lambdas simultaneously, wait for 30 seconds of data collection, and print a consolidated report.

make run-test

3. Clean up

Remove local build artifacts and Terraform plans.

make clean

To destroy infrastructure:

cd terraform && terraform destroy

Statistics Provided

The final report includes:

  • Min/Max: Extreme latency values captured.
  • Mean (Avg): Average latency.
  • p50 (Median): 50th percentile.
  • p95/p99: Tail latency indicators (critical for trading).
  • StdDev: Stability of the connection.
  • Count: Number of messages processed during the window.

Important Note

The Spain region (eu-south-2) may need to be explicitly enabled in your AWS Account console to avoid deployment errors.