Skip to content

AdeSam11/Fast_Search_Server

Repository files navigation

FastSearch Server

Note: This project is a high-performance, SSL-enabled text search server designed to handle thousands of concurrent TCP client connections. It reads a configuration file that specifies a target text file path (linuxpath), performs full-line search queries for exact matches, and responds with either STRING EXISTS or STRING NOT FOUND. The server supports PSK-based SSL authentication, multithreading for concurrency, and can be deployed as a Linux daemon using systemd or run manually for development and testing.

Files of interest (where to look first)

  • fastSearch/main_server.py — main server implementation (entry point)
  • fastSearch/config.txt — example configuration (contains linuxpath=, REREAD_ON_QUERY, SSL_ENABLED, PSK_* entries)
  • fastSearch/etc/systemd/system/fastsearch.service — systemd unit file to run server as daemon
  • fastSearch/tests/ — pytest tests; for unit testing of exceptions and edge cases

Installation (Ubuntu / WSL) — recommended steps

These steps assume you want to install the service on an Ubuntu system (or WSL Ubuntu). The systemd file expects the installation path /opt/fastsearch, but you can choose your preferred path — if you do, update the systemd unit accordingly.

  1. Install WSL If not Installed already
wsl --install

Then reboot

  1. Open Ubuntu from your Start Menu

  2. Navigate to the project folder

cd /path/to/fastsearch 
  1. Run the script
chmod +x install_fastsearch.sh
./install_fastsearch.sh

SSL-PSK Setup

If you enable ssl_enabled=true in config.txt, the installer automatically:

Generates a random PSK token at /path/to/fastsearch_psk.txt Generates a random PSK Identity at /path/to/fastsearch_psk_identity.txt Injects the PSK token and identity values into config.txt Starts FastSearch with secure TLS-PSK authentication

Running the server manually

In the project directory

source .venv/bin/activate
pip install -r requirements.txt
python main_server.py
# or
python main_server.py --daemonize # to run a daemonized server (compatible with Windows systems only)
# To stop the daemonized server
python main_server.py --stop

The server will bind to the configured port and log debug messages to stdout. The logs should also contain DEBUG: markers with query, requesting IP, and timing.

Running the client

Open a different terminal and run

python client.py <host> <port> "<query>" # for where SSL is False in config
python client.py 127.0.0.1 44445 "searchMe" # Real example command - assuming SSL is False

If SSL is enabled in the config, the PSK token and PSK identity must already be set. Update the client script with these values from the server before running:

python client.py <host> <port> "<query>" --true # SSL is True in config
python client.py 127.0.0.1 44445 "searchMe" --true # Real example command - assuming SSL is True

Author: Samuel Adetoyinbo Software Engineer • Algorithmic Sciences

About

A high-performance, concurrent TCP server built to deliver lightning-fast text search over massive files. It uses memory-mapped I/O (mmap) for near-instant access and optimized throughput. Supports both thread-per-connection and bounded thread pools, showcasing real-world concurrency tradeoffs. Clone it to explore its performance. 💥

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors