Skip to content

Cloudslab/Serv-Drishti

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Serv-Drishti: An Interactive Serverless Function Request Simulation Engine and Visualiser

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.

At a glance

  • 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

Contents

  • src/index.html: Single-page application with all views and controls
  • src/main.js: Application coordinator (initialization, charts, metrics tables)
  • src/core/: Core simulation engine, chart manager, and placement algorithms
  • src/features/: Battleground, data export, live metrics, placement analytics
  • src/ui/: Configuration manager, UI event handlers, notification system
  • src/utils.js: Input validation, error handling, performance monitor, debouncers
  • paper/Serv-Drishti.pdf: Conference paper describing the platform (reference only)

Core logic

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.
  • 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
  • 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.

Core simulation components

  • 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.

Features

  • 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: Centralizes globalConfig, validates/syncs UI controls, notifies listeners.
    • event-handlers.js: Wires all controls, tabs, tutorial, scenarios, and downloads.
    • notification.js: Accessible, styled notifications.

Extensibility

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 in index.html + ui/event-handlers.js.
  • Placement algorithms

    • Add a static method to PlacementAlgorithm and include it in the globalConfig.placementAlgorithms list (ui/config-manager.js).
  • Metrics and charts

    • Add series to ServerlessSimulation.timeSeriesData / resourceMetrics / infrastructureMetrics and a corresponding update method in ChartManager.
  • Data export

    • Extend DataExportManager with new CSV/JSON schemas or additional chart downloads.

All modules are namespaced on window.* for simplicity and testability without a bundler.


Usage guide

Serv-Drishti runs locally in a browser. No build steps are needed.

Quick start

  1. Open src/index.html in a modern browser. If your browser blocks local file access for modules/assets, serve the src/ folder with any static server, e.g.:
    • Python: python3 -m http.server 8000 (then visit http://localhost:8000/src/)
  2. On the Welcome page, click “Start Simulation” or “Go to Visualizer”.
  3. 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”.
  4. Explore charts: Latest Requests, Simulation (cumulative), Resource Utilization, Cold Starts.
  5. Use “Detailed Metrics” to inspect tables; start/stop live updates automatically when switching tabs.
  6. Export data (CSV/JSON) and download charts (PNG) via the provided buttons.

Battleground comparison

  1. Switch to the “Battleground” tab.
  2. Select routing and placement for Arena A and B.
  3. Trigger single requests for both or set a synchronized auto rate.
  4. Compare latency, throughput, resource utilization, active functions/nodes, and cost.

Placement analysis

  1. Switch to “Placement Analysis”.
  2. Choose an algorithm in Visualizer and generate requests.
  3. Refresh charts to compare algorithm performance and distribution.
  4. Clear accumulated algorithm data if needed.

Resetting

  • Use “Reset Visualiser” to clear state, charts, logs, and restore defaults.
  • In Battleground, use “Reset Battleground”.

Browser support and dependencies

  • 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.

Citing this work

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.


License

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.

Hosted demo

A publicly hosted deployment of Serv-Drishti is available at: serv-drishti.siddharthagarwal.net

About

Serv-Drishti: An Interactive Serverless Function Request Simulation Engine and Visualiser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published