Skip to content

Morphenoed/distributed-stock-exchange

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Distributed Stock Exchange System

A fault-tolerant distributed stock exchange simulation with multiple server replicas and interactive clients.

Overview

The system allows clients to:

  • deposit and withdraw money
  • deposit and withdraw stocks
  • place buy and sell orders
  • view the current market state

Main Features

  • server discovery via UDP broadcast
  • client connection to the best available server based on RTT
  • leader election between servers
  • reliable FIFO multicast replication
  • crash detection and failover
  • leader-based order matching
  • replicated order book state across servers

How It Works

  • Clients listen for server heartbeat broadcasts and connect to the best available server.
  • Servers discover each other through broadcast and maintain a shared group view.
  • One server becomes the leader and handles order matching.
  • Updates are propagated to the other servers using multicast.
  • If a server crashes, the system updates membership and elects a new leader if needed.

Files

  • client.py — client node implementation
  • server.py — server node implementation
  • report.pdf — final course report

Requirements

Install the only external dependency:

pip install netifaces

Network Requirements

The system relies on UDP broadcast for server discovery and IP multicast for message replication.

Because both mechanisms operate only within a local network, all servers and clients must run on the same machine or within the same LAN subnet.

Running the Project

Start one or more servers:

python server.py

Start one or more clients:

python client.py

Simulating Failure

On a server terminal, type:

crash

This simulates a server failure and allows you to observe failover and leader re-election.

Authors

  • Muhammad Amin Guluzade
  • Eric Sîrbu
  • Mykhailo Zelia

This project was developed as part of a Distributed Systems course.

About

Fault-tolerant distributed stock exchange simulation with leader election, multicast replication, and failover.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages