How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (2024)

InterviewReady

39,076 followers

  • Report this post

How many socket connections can one server handle?10,000?20,000?The answer might surprise you.1. Server PortsMany engineers believe that each socket takes one port to listen to. If this were true, we would be limited to 65,535 sockets.This isn't true.A socket is a logical object, that consists of three things:An IP AddressA transport protocolA port numberThat's why multiple clients can connect to the same 8080 port on most servers. The same port number can be used by multiple sockets!So, there is no limit to the number of sockets in terms of ports.2. Linux File DescriptorsIsn't a socket just a file? Is listening to a socket equivalent to reading a file?Yes. Absolutely.Aha, so the limit to the number of sockets we can open is the number of file descriptors allowed by the machine. In Linux, that's 590432.Well, you could always go to the Linux Kernel and change the limit! This is something we need to do as system engineers of Chat Applications, Live Streaming Apps, and Gaming Platforms to host millions of sockets on a single server. As Pirates of the Caribbean tells us: "These aren't rules as much as guidelines."So, engineers get to break them!3. Theoretical LimitAs mentioned above, Sockets are defined by IP Address, Protocol, and Port. If we specify the protocol, like TCP, we are left with Port and IP Address identifiers.Isn't that a limit? 2^16 ports coupled with 2^32 IP addresses would be a limited (albeit massive) number of 2^48 sockets per machine. Yes! That's the upper limit we have on sockets. Currently, a machine can host at most 281 trillion sockets.But there is a catch. Connections and sockets are different concepts!Every connection has two sockets. One on the client and one on the server.One server socket can be used to maintain multiple connections. This means that there really is no limit to the number of users who can connect to your cloud server.Theoretically.-----------------------------WebSockets, Network Protocols, and Operating System limits are concepts that determine the feasibility of popular apps. As a software engineer, it makes sense to know about these concepts in depth. Our system design course at InterviewReady is filled with engineering knowledge nuggets.Handling Connections at Scale: https://lnkd.in/dbbpxWBhConnection Related Thundering Herds:https://lnkd.in/ddxKwpSANetworks Deep Dive: https://lnkd.in/dPXfpwNHYou are worth the investment. Cheers!

  • How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (2)

301

11 Comments

Like Comment

Utkarsh Srivastava

Software Engineer @IBM Storage | Partner Engineer @RedHat

12mo

  • Report this comment

This is completely based on my assumption and I might be wrong.What about each fd's memory consumption? Assuming each fd consumes 1k then 2^30 will already consume 1TB memory?

Like Reply

1Reaction 2Reactions

Farhad Shiri

Lead Technical Architect

12mo

  • Report this comment

InterviewReadyit's definitely impossible to manage several million sockets on a server even if it has very strong hardware resources1- the first and biggest problem in socket management is this, how is the piece of the code responsible for handling each socket programmed for sending/receiving?2- even if we have a large number of processor cores, binding each socket to each core will face computational limitations.3- even if we use I/O multiplex, the kernel itself will have a limit on the number of IO port a per process.4- assuming that we have enough memory to store a few million sockets, we will still easily suffer from kernel panic and memory killer.and many more...of course, in real-time software systems, there is no need to maintain several million sockets, because basically, such scenarios should be designed in such a way that they perform their tasks in very short time cycles and restore all system resources to the process.

Like Reply

2Reactions 3Reactions

Akshay Rajpurohit

Engineering @ Rhythm

12mo

  • Report this comment

This post sums up the research I had to do for a POC a few months ago. There's a library called μWebSockets whose author has written some really good articles on the same topic on Medium. Pretty cool stuff!

Like Reply

3Reactions 4Reactions

Syed Mujtaba

MS CS @ UC San Diego | GSoC '24 @ SPCL | ICPC Regionalist | Ex SDE-2 @ Trilogy | Software Engineer | AWS, Go, Python, Kubernetes, Distributed Systems, Cloud, Serverless, GenAI

12mo

  • Report this comment

Why is it 2^32 IP Addresses?Why isn't it more than that considering IPV6...

Like Reply

1Reaction

Shiva Raman Pandey

Principal Architect | Microservices | Cloud Native | ex-CoinDCX | ex-Cyware | UC Berkeley

12mo

  • Report this comment

Why did you assume all 2^31 IP addresses on a single server? This is limited to the number of physical or virtual layer 2 cards they have, usually not more than 100.

Like Reply

1Reaction

Noor Ahmed

Full Stack NestJS | Express JS | NodeJS | Javascript | Vue JS | PHP | Laravel | Yii

12mo

  • Report this comment

Husnain warraich interesting post

Like Reply

1Reaction 2Reactions

Md Balal Raza

Engineering at Bhanzu

12mo

  • Report this comment

Beautiful! Thank you for sharing this.

Like Reply

1Reaction 2Reactions

Gal Aviezri 🎗️

Software Engineer | B.Sc Computer Sciences

12mo

  • Report this comment

Omri Shahar

Like Reply

1Reaction

See more comments

To view or add a comment, sign in

More Relevant Posts

  • InterviewReady

    39,076 followers

    • Report this post

    Hey all! Do you have any queries about system design?If so, don't forget to join the Zoom class tomorrow!To add all of our Zoom classes to your schedule, integrate your Google Calendar. Over 20,000 engineers have joined us to learn about System Design. We are glad to be a part of your journey.Here is the link: https://lnkd.in/dvcAbyWDSee you tomorrow!#systemdesign #whitepaper #database

    • How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (15)

    9

    Like Comment

    To view or add a comment, sign in

  • InterviewReady

    39,076 followers

    See Also
    TCP Socket

    • Report this post

    Why are Content Delivery Networks (CDN) so popular?Delivering content across the globe quickly is a huge challenge. Since low latency is an indicator of high quality (Amazon and Google studies show a direct correlation between website latency and sales), developers are constantly looking to make their web pages faster. Content Delivery Networks (CDNs) are vital to this effort.1️⃣ CDNs are servers deployed across the globe, allowing users to connect to nearby servers.2️⃣ This improves availability, and spreads request load, reducing single points of failure.3️⃣ The shorter round trips and reduced bandwidth usage translate to reduced tech costs.4️⃣ Websites can use these systems as a black box, with negligible maintainence and setup costs.Key components:1. Origin Server: The principal source of content.2. Edge servers: Caches dispersed to provide content.3. DNS: Directs requests to the closest edge server.4. Control Plane: Manages CDN infrastructure.Popular CDN providers:1. Cloudflare2. Akamai3. Amazon CloudFront4. FastlyUseful tips:1. Use appropriate TTLs, else content updates result in restarts :p 2. CDNs are great for DDoS protection. 3. You can set content-specific optimizations in them, like image compressions.4. Choose a suitable caching strategy for the CDN servers.Have you used CDNs in your projects, and if so how did you keep them up to date?#SystemDesign #CDN #Interviewready

    10

    Like Comment

    To view or add a comment, sign in

  • InterviewReady

    39,076 followers

    • Report this post

    This is a must read if you are a senior software or data engineer.The Google Dremel Paper explains how to efficiently run ad-hoc queries. This 10-page article lists the challenges of running queries on huge datasets, along with amazing solutions.Key points:1. Running aggregate queries like count, max, and min quickly on huge data sets is a challenge. For example, “How many users from Bangalore frequently move and search for cars?”2. Dremel runs on thousands of nodes for parallelism. 3. It uses a multi-level serving tree, inspired by distributed search engines, to run parallel queries.4. It has a query optimizer, similar to those in SQL databases but optimized for distributed execution.5. Dremel represents data in columnar form to allow rapid scans.6. It uses algorithms like Finite Automata and modified Segment Trees.What makes Dremel amazing:1. Dremel was awarded as the VLDB 2020 Test of Time winner. Systems like Apache Impala have been designed based on Dremel.2. Dremel allows interactive queries on petabyte-sized datasets efficiently.3. It handles deeply nested data and executes massively distributed queries.To learn more about software engineering and system design, check out our course: https://interviewready.io/#SystemDesign #Google #Engineering

    InterviewReady | System Design Course | Gaurav Sen interviewready.io

    7

    Like Comment

    To view or add a comment, sign in

  • InterviewReady

    39,076 followers

    • Report this post

    Load balancers are like traffic cops on the internet 🚦Here's how they work:1️⃣ Clients send requests to a gateway (a server accepting external requests).2️⃣ The gateway talks to the load balancer, which selects the best machine to serve this request.3️⃣ The gateway then forwards this request to the assigned server.4️⃣ Everyone is happy.That's it. The benefits of this approach are:1. Scalability: Servers can be added/removed efficiently2. High availability: Traffic is re-directed from failed servers to healthy servers3. Performance: Work is evenly distributed for smaller worst-case request queue size (improving worst-case response times)Commonly employed algorithms include:1. Round Robin: Go through servers one by one using an iterator.2. Least Connections: Send requests to the server having the fewest active connections.3. IP Hash: Use the client’s IP to select a server for session persistence (caching is awesome).Useful tips: 1. Load balancing can be on layer 4 (transport level) and layer 7 (application level).2. Regularly check the health of servers to decide on adding or removing a few.3. SSL termination helps offload encryption headaches.Have you used a load balancer in your system, and if so what algorithm did you use?Watch this video on load balancer here:Link: https://lnkd.in/dtqhwAsd#LoadBalancer #SystemDesign #Developers

    • How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (24)

    47

    1 Comment

    Like Comment

    To view or add a comment, sign in

  • InterviewReady

    39,076 followers

    • Report this post

    We wish you a very Happy Ganesh Chaturthi!May Bappa bless you with wisdom, prosperity and happiness on this auspicious occasion. 🌺Ganpati Bappa Morya! 🙏#ganeshchaturthi #india #festival

    • How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (29)

    11

    Like Comment

    To view or add a comment, sign in

  • InterviewReady

    39,076 followers

    • Report this post

    This case study shows how Canva collects 25 Billion events per day.Challenges:1. Canva has more than 175 million monthly active-users2. Users connect on different platforms like iOS, android, web, and desktop apps3. More than 25 Billion events are generated per day4. SLAs of 99.999% uptime.Canva's Solution:Canva first tried using AWS SQS and SNS for event ingestion.After examining these options, they decided to go with AWS Kinesis Data Streams.There are a few reasons Kinesis made sense:1. Significantly lower cost of operating (85% less compared to SQS/SNS)2. Real-time data streaming with sub-second latency3. Scalable (necessary to handle massive event volumes)4. Seamless integration with other Amazon Web Services (AWS) services.5. Data can be retained and replayed. This is a standard Event Sourcing benefit.Results:1. Canva now manages 25 billion events per day.2. The cost of their Kinesis solution is 85% less than that of running SQS/SNS.3. Annual savings of $600k due to event compression.4. Meeting the requirement of 99.999% uptime as requested.Key Takeaways:1. The right data streaming service can dramatically impact costs at scale. The scale affects pricing significantly.2. Batching and compression strategies can lead to significant savings. Memory and bandwidth are saved through batching and compression.3. Decoupling ingestion from processing helps with scalability. Think of the CQRS pattern.4. A hybrid approach (Kinesis + SQS) can address different processing needs effectively. This allows Canva to serve a wide range of data analytics use cases.This case study shows that choosing the right tech, with practical improvements like compression, can massively reduce costs. Did you face similar challenges when building a data pipeline?Let me know in the comments!#Canva #SystemDesign #CaseStudy

    • How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (33)

    99

    4 Comments

    Like Comment

    To view or add a comment, sign in

  • InterviewReady

    39,076 followers

    • Report this post

    "Cache me if you can" 🏃 But what is CACHING?Caching is the practice of copying frequently accessed data into memory. Subsequent requests for the same data are served quickly from memory, instead of a slow database. The goal of caching is to reduce latency by avoiding database calls.Here are 4 commonly used caching techniques:🔷 Write-Behind Pattern:Writes are immediately acknowledged in the cache and asynchronously updated in the database. This reduces write latency and handles high write loads efficiently, but risks data loss if the system fails before persisting to the database. Ideal for scenarios prioritizing write performance over immediate consistency.🔷 Refresh-Ahead Pattern:Proactively updates cached data before expiration based on predicted access patterns. This reduces read latency for frequently accessed data but may waste resources updating unused data. Best for systems with predictable access patterns requiring minimal read latency.🔷 Write-Through Pattern:Simultaneously writes data to both cache and database in a single transaction. Ensures strong data consistency but increases write latency. Suitable for applications requiring data integrity and consistency, tolerating slower write operations.🔷 Write-Around Pattern:Bypasses the cache for writes, updating only the database. The cache is populated on read operations. This prevents cache pollution from write-heavy workloads but can increase read latency for recently written data. Effective for systems with high write volumes and infrequent reads of new data.The right caching strategy depends on system requirements and constraints. It's often useful to think of a hybrid caching strategy based on system tradeoffs.-------Checkout our website & see how you can upskill: https://interviewready.io/#caching #systemdesign #interview

    • How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (38)

    146

    4 Comments

    Like Comment

    To view or add a comment, sign in

  • InterviewReady

    39,076 followers

    • Report this post

    Some low-level design patterns for senior engineers:1. Read your writes: https://lnkd.in/dJYZ3Z_72. Asynchronous Processing with Futures: https://lnkd.in/d55-j-G83. Request Collapsing: https://lnkd.in/dFbJmwJC4. What are threads: https://lnkd.in/dF4q9ez25. Ordering requests with threads: https://lnkd.in/dV_fqwW86. Event Bus Publishers and Subscribers: https://lnkd.in/dcciJ4vM7. What is a software client library: https://lnkd.in/dbYzNXeH8. Classes and package structuring: https://lnkd.in/dqagPDG99. Dependency Inversion: https://lnkd.in/djU2uw4K10. What is backpressure: https://lnkd.in/dksjQb7NIf you work as a software engineer, you are probably using a few of these patterns already :DCheers!#SoftwareEngineering #LowLevelDesign #DesignPatterns

    28

    Like Comment

    To view or add a comment, sign in

  • InterviewReady

    39,076 followers

    • Report this post

    Last one day left before we close the offer & thank you for all the love and enthusiasm you all have shown!For everyone who has registered for the course, we cannot wait to meet you all in the live class ❤️ and for those who missed the sale we have good news for you -Last ONE DAY before we close the 70% offer on our system design course.Take a step towards your dream job and grab your course NOW 👇https://interviewready.io/Code: DESIGN70#sale #discount #systemdesign

    • How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (46)

    5

    Like Comment

    To view or add a comment, sign in

  • InterviewReady

    39,076 followers

    • Report this post

    System design of Zerodha is a popular interview question asked in tech companies.The idea is to see how candidates design a real-time large-scale distributed system that can accept buy and sell orders.In this design question, you are asked to place the missing components in the marked boxes. We also have a capacity estimation question to test your math skills!Design Link: https://lnkd.in/dF-9Tb4RThe month-end sale is live - Get 70% off on the System Design course!Buy course: http://interviewready.io/

    • How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (49)

    8

    Like Comment

    To view or add a comment, sign in

How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (51)

How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (52)

39,076 followers

View Profile

Follow

More from this author

  • How to Read Engineering Research Papers InterviewReady 8mo
  • Database Indexing Strategies: How NoSQL outperforms traditional indexing InterviewReady 1y

Explore topics

  • Sales
  • Marketing
  • IT Services
  • Business Administration
  • HR Management
  • Engineering
  • Soft Skills
  • See All
How many socket connections can one server handle? | InterviewReady posted on the topic | LinkedIn (2024)
Top Articles
Travelex Canada money transfer: Fees, rates and transfer times
Travelex travel card: Foreign currency rates and fees explained
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
How To Cut Eelgrass Grounded
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Dmv In Anoka
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Umn Biology
Obituaries, 2001 | El Paso County, TXGenWeb
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Colin Donnell Lpsg
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Used Curio Cabinets For Sale Near Me
San Pedro Sula To Miami Google Flights
Selly Medaline
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 6753

Rating: 4.2 / 5 (43 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.