---
title: "SimThesis"
year: "2021"
motto: "Discrete-Event Queue Simulation Tool"
description: "Online discrete-event queue simulation tool built with \"General Simulation Framework\" as a validation tool of the framework's capabilities."
stack: ["python", "flask", "socketio", "vuejs", "typescript", "nodejs"]
website: "https://simulab.onrender.com"
url: "https://rolandoandrade.me/projects/simthesis/"
author: "Rolando Andrade"
---

# SimThesis

> Discrete-Event Queue Simulation Tool

Online discrete-event queue simulation tool built with "General Simulation Framework" as a validation tool of the framework's capabilities.

Year: 2021. Stack: python, flask, socketio, vuejs, typescript, nodejs. Website: https://simulab.onrender.com

On paper, a queue is simple. Customers arrive. They wait in line. A server helps them. They leave. Predicting how a real queue behaves is much harder. How long will customers wait on average? How many servers keep the wait reasonable? At what point does the line grow without end?

These questions matter in real systems. Banks, hospitals, call centers and web servers all deal with queues. A bad prediction means angry customers or wasted resources.

I built SimThesis to answer these questions with simulation. It runs in the browser. You describe your queue system, and the tool shows you how it behaves over time.

## Where formulas stop working

Simple queue systems have mathematical formulas. An M/M/1 queue has random arrivals, random service times and one server. It has exact formulas for the average wait and the average line length. Real systems are rarely that simple.

What if arrivals are not random? What if service times follow another distribution? What if there are several servers with different speeds? What if customers leave after waiting too long?

Each of these breaks the simple formulas. Simulation still works. You model the system as you understand it. The simulator runs thousands of virtual customers through it and reports what happens.

## Jumping from event to event

SimThesis uses discrete event simulation. Time does not flow smoothly. The simulator jumps from one event to the next: an arrival, then a service completion, then another arrival. It handles the events in order and tracks the state of the system.

You set up the simulation in a web interface. You pick probability distributions for arrivals and for each server's service time. You choose the number of servers and how many people fit in the queue.

The simulator runs your setup and streams results back live. You watch the queue grow and shrink. Charts show wait times, queue lengths and how busy each server is.

## A test for the framework

SimThesis exists to validate the [General Simulation Framework](/projects/general-simulation-framework/). That framework gives you building blocks for simulation tools: entities, resources, events, queues and statistical collectors. Building blocks mean nothing until you prove they work.

A queue simulator is a perfect test. Queue theory gives known results to compare against. If the simulator produces the expected average wait for an M/M/1 queue, the framework works.

SimThesis passed. The simulated results matched the theory. That gave me confidence to use the framework for more complex applications.

## Live charts with Socket.IO

Simulations take time. Running a million customers through a queue takes more than a few milliseconds. Users need feedback while they wait.

Socket.IO carries messages between the server and the browser over a connection that stays open. The Python backend runs the simulation and sends progress updates. The Vue.js frontend receives them and draws them right away.

The chart updates as new data arrives. Users see the queue length go up and down. They watch the average wait settle as the simulation collects more data. The tool feels responsive even during long runs.

The heavy computing stays on the server, and the browser only draws. That split keeps the simulation fast and the interface smooth.

## The event loop

Discrete event simulation follows one pattern:

1. Keep a priority queue of future events, sorted by time.
2. Take the next event.
3. Process it.
4. Schedule any new events it creates.
5. Repeat until done.

An arrival event creates a customer. If a server is free, the customer starts service right away. If not, they join the queue. The arrival event also schedules the next arrival.

A service completion event frees the server. If customers are waiting, the next one starts service. The completion schedules the departure.

This loop can model systems of any complexity. You add new event types for new behaviors. The core algorithm stays the same.

## Turning runs into statistics

Raw simulation data means little without analysis. SimThesis collects statistics during each run: average wait time, maximum queue length, server utilization and confidence intervals around the estimates.

The collector handles the warm up period. Early data is unreliable because the system starts empty. The tool throws away those first samples before computing the final numbers.

Batch means help estimate confidence intervals. The tool groups samples into batches and measures how much the batch averages vary. That variation tells us how much to trust the overall average.

## Choosing distributions

Queue behavior depends a lot on the distributions you choose. SimThesis supports the common ones:

- Exponential for random arrival processes
- Normal for service times with natural variation
- Uniform for bounded random values
- Deterministic for fixed intervals

You enter each distribution's parameters in the interface. Exponential needs a rate. Normal needs a mean and a standard deviation. The backend checks the inputs before it runs.

The choice matters. Exponential arrivals with exponential service give the classic M/M/1 queue. Change either one and the behavior changes too.

## Python, Flask and Vue

The backend runs Python with Flask. Flask handles the HTTP requests that set up and control a simulation. The General Simulation Framework is the simulation engine.

Socket.IO adds the live updates. The simulation sends them as it runs, and Flask-SocketIO connects Python to the WebSocket protocol.

The frontend uses Vue.js with TypeScript. Components handle the setup forms, the results and the live charts. TypeScript catches type errors before they reach production.

Node.js serves the frontend during development. In production, the static files deploy apart from the Python backend.

## Tuning the updates

Live updates needed careful design. Send them too often and the network floods. Send them too rarely and the interface feels slow. I settled on grouping updates every few units of simulation time.

Browser speed needed attention too. Drawing thousands of points on a chart slows everything down. I limited the visible window of data and combined older samples.

The General Simulation Framework also needed changes for the web. Its original design assumed batch processing. I added hooks for progress callbacks and for stopping a run early.

## Tools that test tools

SimThesis taught me how simulation engines work inside. The discrete event pattern applies beyond queues. Manufacturing systems, computer networks and logistics all use it.

I learned how to analyze simulation output. Confidence intervals need care. Samples that depend on each other (autocorrelation) make variance harder to estimate. The warm up problem affects every simulation study.

I also learned to build interactive charts. Streaming data to a browser chart has its own problems. Finding the right balance between update speed and performance took experiments.

Most of all, SimThesis validated a bigger piece of work. The General Simulation Framework became more credible because SimThesis worked. Building tools to test your tools is time well spent.

[Book a call with Rolando](https://rolandoandrade.me/pricing/)
