Serv-Drishti is an interactive, browser-based platform for studying serverless computing behavior through live simulation, visualization, and analysis. It models request routing, function instance lifecycle (including cold starts and scale-down), placement strategies across compute nodes, and presents rich metrics and export capabilities suitable for research and teaching.
This repository contains an entirely client-side implementation that runs in modern browsers without build steps or backend services.
- Interactive simulation of serverless request flows with visual architecture
- Multiple routing logics and placement algorithms
- Real-time charts for latency, resource utilization, and cold starts
- “Battleground” mode for side-by-side strategy comparison
- Detailed metrics tables and data export (CSV/JSON/PNG)
- Modular, extensible code organized by core, UI, and features
src/index.html
: Single-page application with all views and controlssrc/main.js
: Application coordinator (initialization, charts, metrics tables)src/core/
: Core simulation engine, chart manager, and placement algorithmssrc/features/
: Battleground, data export, live metrics, placement analyticssrc/ui/
: Configuration manager, UI event handlers, notification systemsrc/utils.js
: Input validation, error handling, performance monitor, debouncerspaper/Serv-Drishti.pdf
: Conference paper describing the platform (reference only)
Serv-Drishti models a simplified serverless platform with the following lifecycle and behaviors:
-
Request ingestion and routing
- Requests enter via a simulated API Gateway and Dispatcher.
- Routing logic assigns requests to available function instances with capacity or queues them if none are available.
- Supported routing logics (implemented):
- Warm Priority (
current
): Prefer warm instances; queue; scale out if needed. - Round Robin (
round-robin
): Cycle across available instances. - Least Connections (
least-connections
): Choose instance with lowest active concurrency.
- Warm Priority (
-
Function instance lifecycle
- Instances cold start with a base delay adjusted by system load and queue length; warm instances serve requests immediately.
- Concurrency per instance is bounded by
Max Concurrent Requests (n)
. - Inactivity triggers scale-down (instance removal) after a configurable timeout.
- Function failures are simulated when execution exceeds
Function Max Timeout
or when hosting nodes fail.
-
Compute nodes and placement
- New function instances are placed onto nodes subject to CPU/Memory capacity and
Max Functions per Node
. - When no node can host a function and
Max Nodes
is not reached, a new node is provisioned. - Supported placement algorithms (implemented):
- First Fit, Best Fit, Worst Fit
- Load Balanced
- Affinity / Anti-affinity
- Cost Optimized
- New function instances are placed onto nodes subject to CPU/Memory capacity and
-
Timing and cost model
- Request latency = queue wait + execution time.
- Execution time is influenced by per-instance concurrency and routing effects; additional fixed penalty from queue length (network congestion).
- Simple cost model: execution time (s) × memory (MB) per request; cumulative cost tracked over time.
-
ServerlessSimulation
(src/core/simulation.js
)- Owns per-simulation state: nodes, function instances, queues, metrics, time series, costs.
- Manages lifecycle: request handling, dispatching, queuing/TTL, cold start, execution timers, failures, cleanup/scale-down.
- Produces logs for requests, functions, and nodes; updates DOM visuals and metric tables.
-
ChartManager
(src/core/chart-manager.js
)- Safe Chart.js integration with compatibility layer and debounced updates.
- Charts (implemented):
- Latest Requests (session) and Simulation Results (cumulative)
- Resource Utilization & Queue Metrics (time series)
- Cold Start Times
- Placement: performance, distribution, efficiency (framework present; fed by Placement Analytics)
-
PlacementAlgorithm
(src/core/placement-algorithms.js
)- Selects target node for new function instance given CPU/Memory and placement policy.
- Includes helpers for capacity checks and utilization analysis.
-
Cross-cutting utilities (
src/utils.js
)- Input validation and sanitization, error handling and safe execution, performance marks, debounce/throttle, and a chart-update debouncer.
-
Battleground (
src/features/battleground.js
)- Two parallel simulations (Arena A, Arena B) with independent routing/placement settings.
- Comparative charts for latency, throughput, resource usage, function/node counts, and cumulative cost.
-
Live Metrics (
src/features/live-metrics.js
)- Periodic updates of detailed tables for functions, nodes, and recent requests.
-
Placement Analytics (
src/features/placement-analytics.js
)- Aggregates recent main-simulation results into per-algorithm metrics and time series; drives placement charts.
-
Data Export (
src/features/data-export.js
)- Export main simulation data and battleground metrics as CSV/JSON.
- Export charts as PNG (Simulation, Resource, Battleground, Latest, Placement).
-
UI Layer (
src/ui/*
)config-manager.js
: CentralizesglobalConfig
, validates/syncs UI controls, notifies listeners.event-handlers.js
: Wires all controls, tabs, tutorial, scenarios, and downloads.notification.js
: Accessible, styled notifications.
The codebase is modular by design, with clear extension points:
-
Routing strategies
- Extend
ServerlessSimulation.findAvailableFunction()
to add a new routing policy and wire a radio button inindex.html
+ui/event-handlers.js
.
- Extend
-
Placement algorithms
- Add a static method to
PlacementAlgorithm
and include it in theglobalConfig.placementAlgorithms
list (ui/config-manager.js
).
- Add a static method to
-
Metrics and charts
- Add series to
ServerlessSimulation.timeSeriesData
/resourceMetrics
/infrastructureMetrics
and a corresponding update method inChartManager
.
- Add series to
-
Data export
- Extend
DataExportManager
with new CSV/JSON schemas or additional chart downloads.
- Extend
All modules are namespaced on window.*
for simplicity and testability without a bundler.
Serv-Drishti runs locally in a browser. No build steps are needed.
- Open
src/index.html
in a modern browser. If your browser blocks local file access for modules/assets, serve thesrc/
folder with any static server, e.g.:- Python:
python3 -m http.server 8000
(then visithttp://localhost:8000/src/
)
- Python:
- On the Welcome page, click “Start Simulation” or “Go to Visualizer”.
- In Visualizer:
- Adjust “Core Simulation Settings” (concurrency, nodes, cold start, timeouts).
- Choose a “Placement Algorithm”.
- Click “Simulate Single Request”, or set “Auto Request Rate” and click “Start Auto”.
- Explore charts: Latest Requests, Simulation (cumulative), Resource Utilization, Cold Starts.
- Use “Detailed Metrics” to inspect tables; start/stop live updates automatically when switching tabs.
- Export data (CSV/JSON) and download charts (PNG) via the provided buttons.
- Switch to the “Battleground” tab.
- Select routing and placement for Arena A and B.
- Trigger single requests for both or set a synchronized auto rate.
- Compare latency, throughput, resource utilization, active functions/nodes, and cost.
- Switch to “Placement Analysis”.
- Choose an algorithm in Visualizer and generate requests.
- Refresh charts to compare algorithm performance and distribution.
- Clear accumulated algorithm data if needed.
- Use “Reset Visualiser” to clear state, charts, logs, and restore defaults.
- In Battleground, use “Reset Battleground”.
- Modern browsers (tested with Chrome, Firefox and Safari).
- Charts: Chart.js loaded from CDN with fallback and graceful degradation; when unavailable, charts are disabled but the app remains usable.
- No server-side components.
If you use Serv-Drishti in academic work, please cite the accompanying paper in paper/Serv-Drishti.pdf
. This README intentionally summarizes the implemented functionality and may skip some intricate details of the actual code and the paper.
Licensed under the Apache License, Version 2.0. See LICENSE
.
Copyright (c) 2025 Siddharth Agarwal
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
A publicly hosted deployment of Serv-Drishti is available at: serv-drishti.siddharthagarwal.net