Into AI

Into AI

Share this post

Into AI
Into AI
Multi-Threading Is Not Always The Right Answer. Here's Why!

Multi-Threading Is Not Always The Right Answer. Here's Why!

Learn to scale a server using Multithreading, Busy waiting and the Reactor pattern.

Dr. Ashish Bamania's avatar
Dr. Ashish Bamania
Aug 26, 2023
∙ Paid
1

Share this post

Into AI
Into AI
Multi-Threading Is Not Always The Right Answer. Here's Why!
Share
Photo by John Cameron on Unsplash

Modern software engineering is all about making applications efficient.

Concurrency is thus a critical aspect as modern applications perform multiple tasks simultaneously and maximize hardware utilization.

Byte Surgery is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.

Let’s learn this better with an example.

We are opening up a small coffee shop and we build a mobile app through which users can place coffee orders online.

Let’s write a simple server that handles these order requests.

from socket import socket, create_server

BUFFER_SIZE = 1024
ADDRESS = ("127.0.0.1", 12345)

class CoffeeServer:
    def __init__(self):
        try:
            self.server_socket = create_server(ADDRESS)
            print("Coffee server started at:", ADDRESS)
        except OSError:
            print("\nCoffee server stopped.")

    def accept(self):
        conn, client_address = self.server_socket.accept…

Keep reading with a 7-day free trial

Subscribe to Into AI to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Dr. Ashish Bamania
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share