Building a Real-Time Chat Server: From Distributed Processing to Performance Optimization

Develop a scalable real-time WebSocket chat server capable of handling high traffic by building a 3-instance cluster with Spring Boot 3.x and Kotlin, utilizing Redis Pub/Sub for distributed messaging and Nginx as a load balancer.

(4.9) 29 reviews

240 learners

Level Beginner

Course period Unlimited

Spring
Spring
Kotlin
Kotlin
Spring Boot
Spring Boot
websocket
websocket
Spring
Spring
Kotlin
Kotlin
Spring Boot
Spring Boot
websocket
websocket

Reviews from Early Learners

Reviews from Early Learners

4.9

5.0

Jlos Ho

100% enrolled

This lecture is also truly Goat. I've taken other courses, but this kind of realistic lecture that feels like someone is teaching you right next to you seems to be unique on this Inflearn platform. It was very helpful. Thank you.

5.0

Hoos

96% enrolled

So this kind of architecture exists... This seems like a great course where many people can understand chat platforms through architecture and actual code for platforms starting from Kotlin.

5.0

미래 1인 개발자

32% enrolled

I'm a Toss server developer, gradually accumulating experience, who helped with server architecture and message processing design for this lecture. Until now, my work focused solely on stateless protocol communication. Filming this new topic was very joyful and interesting. Feel free to leave questions. I'll also watch with interest and hope to share my thoughts on questions. Please show much interest in the lecture.

What you will gain after the course

  • A distributed messaging system that synchronizes real-time messages across multiple server instances using Redis Pub/Sub.

  • How to configure a 3-instance cluster with Docker Compose and distribute traffic using an Nginx load balancer

  • Implement bidirectional real-time communication using Spring WebSocket

  • How to design a scalable server architecture by applying Domain-Driven Design with a multi-module structure

  • Techniques for ensuring message ordering in distributed environments through message sequence management using Redis

  • Service operation methods through Docker container-based deployment, health checks, and log monitoring

  • Modern Backend Development Methods Using the Latest Features of Spring Boot 3.x + Kotlin

  • Defensive coding techniques for stable service operation, such as preventing duplicate message processing, session cleanup, and resource release.

Through this course, you will...

You will directly design and build a scalable server architecture capable of handling tens of thousands of users in a real-world service environment.


🏗. Beyond simply implementing features, you will gain hands-on experience with the core principles of distributed systems that operate reliably even under heavy traffic.

First, you will learn how to distribute traffic using an Nginx load balancer 🌐 so that multiple servers operate as a single system, and how to synchronize messages between servers in real-time using Redis Pub/Sub. In this process, you will naturally acquire the know-how to solve the C10K (10,000 concurrent connections) problem.


Additionally, you will gain experience in tuning database connection pools and applying JPA batch processing and cursor-based pagination to improve response times down to the millisecond.

Finally, you will learn stable operational techniques to maintain a consistent environment from development to deployment using Docker containers🐳 and to prevent service failures in advance by building Health Check and monitoring systems🩺. All these processes are implemented with sophisticated and efficient code using the latest stack: Kotlin, Spring Boot 3.x, and WebSocket .

📦After taking this course, you will be able to create these results

One complete distributed chatting application 📦

You will receive a complete application package where the entire system (servers, databases, caches, etc.) can be launched at once with a single command. It is not just a collection of code snippets, but a service ready for immediate deployment.

Production-level system architecture blueprint 🗺

You will directly build and understand a system architecture diagram that covers the entire flow from user requests to data storage. This diagram will serve as an excellent portfolio asset that proves your technical depth.

Real-time bidirectional chat functionality 💬

You will have a completed project where the core chatting features—such as users logging in, creating chat rooms, and exchanging various messages in real-time—are fully implemented.

Horizontally scalable server cluster

You will build a server cluster where n Spring Boot servers operate under an Nginx load balancer. Through this, you will learn how to easily scale the system by simply adding server instances as traffic increases.

High-Availability Messaging System 📡

Build a reliable messaging system where all messages are delivered without loss through Redis Pub/Sub, even if a server failure occurs or users are connected to different servers.

Optimized Data Management System

Complete a hybrid data system that satisfies both data stability and fast response speeds by permanently storing chat data in PostgreSQL and storing session information or cache data in Redis.

📚Key Highlights of the Lecture!

Redis Pub/Sub Distributed Messaging

Implement Redis's publish-subscribe pattern for real-time message synchronization across multiple server instances. We will establish a scalable real-time communication foundation by building a production-level distributed messaging system that handles duplicate message prevention, message ordering, and server-specific isolation.

WebSocket-based Real-time Communication

We implement bidirectional real-time communication that is far more efficient than HTTP by utilizing Spring WebSocket. We provide stable real-time chat functionality through session management, connection status tracking, and error handling, while also applying optimization techniques for problem-solving.

Multi-module DDD Architecture

Separate the API, Domain, Persistence, and WebSocket layers into independent modules according to Domain-Driven Design principles. Build a scalable server architecture that maximizes maintainability and testability by clearly defining the responsibilities of each module and controlling the direction of dependencies.

Nginx Load Balancer + WebSocket Proxy

Configure an Nginx load balancer to evenly distribute traffic across n Spring Boot instances. It reliably proxies not only HTTP requests but also WebSocket connections, establishing a high-availability service environment with production-level reverse proxy settings.

📚A Sneak Peek at the Project Functional Architecture

Redis Pub/Sub

Message Processing Process

📚Course Preview!

📚 Writing a WebSocket Session Management Class In Progress



📚 Server Deployment Using Automated Scripts (In progress)



📚 Docker-Compose for Environment Deployment In Progress



📚 Setting Nginx Performance Metrics (Excerpt)



Why should I learn Kotlin..?

It is said to be 100% compatible with Spring, and the Kotlin language created by JetBrains is optimized for concurrent programming, which is not as well-suited for standard Spring.

📚Concise and intuitive syntax


Because Kotlin provides a concise and intuitive syntax, developers can accomplish more with less code. This has the effect of improving readability and making maintenance easier.

📚 High Productivity and Safety


Kotlin natively supports null safety, which helps reduce NullPointerExceptions. Additionally, it supports functional programming, allowing you to write code in a more functional and declarative manner. These features increase development productivity and reduce the likelihood of bugs.

📚 High Compatibility


Kotlin is 100% compatible with Java, so it can be easily integrated into existing Java projects. This means there are no major barriers for Java developers to learn Kotlin, and they can use new Kotlin features while maintaining existing code.

websocket Can't we just implement it using HTTP? 🤔

📌 It is possible. It is not an impossible development method.

📌 However, server developers generally need to minimize and optimize server resource usage.

📌 Therefore, for communications that require a continuous connection to be maintained, such as a chat server, using WebSocket is highly appropriate.

4 core values I hold dear

1. Lectures must be human.

I believe that a lecture designed only for ease of presentation is not a true lecture, even if it might make me appear less professional. The time spent on debugging is also an integral part of the lecture.

2. It must be specialized for practical work

Development is not done with words. You can experience the process of actual implementation and operation together.

  • Planners... please save me..

3. It must be helpful to the students.

I have tried to incorporate concepts that I personally applied in practice and saw results from. Through this course, you can indirectly experience real-world work, or if you are already a professional, you will be able to demonstrate even better performance in your work environment.

4. The lecture is not the end.

I hope you will leave many questions and answers as you progress through the lecture. This lecture was not created solely through my own knowledge. It also incorporates the opinions of various developers from major corporations.

  • The following is a brief background of the individuals who helped complete this lecture.


private val supported_one = "Kakao Pay Platform Backend Developer" private val supported_two = "Toss Securities API Server Developer" private val supported_three = "Unicorn Startup Server Developer who asked to remain anonymous"

Notes before taking the course

Practice Environment

  • It was filmed using a MacOS M3.

  • Docker is used as a default.

  • java --version : 17.0.12 2024-07-16 LTS

  • I use JetBrains IDEs.

  • Build using Gradle.

    • The source code includes all build files to prevent any potential version conflicts.

😍 Recommended related topics

Recommended for
these people

Who is this course right for?

  • Backend developers who want to grow from junior to mid-level

  • A developer who wants to gain experience in real-time service development

  • A developer interested in distributed systems architecture

  • A mid-level developer who wants to grow into a senior developer

  • Developers with basic knowledge of Docker or developers who want to learn it.

  • Game/Chat/Social Service Developer

  • Job seekers who want to strengthen their portfolios

  • A developer planning to change jobs by expanding their tech stack.

Need to know before starting?

  • It is helpful to have a basic knowledge of Spring.

  • It is helpful to have a basic knowledge of WebSocket communication.

  • You don't need to have all of this knowledge. Since we will be implementing the project ourselves, we can learn together.

Hello
This is Hong

7,493

Learners

461

Reviews

142

Answers

4.7

Rating

25

Courses

Introduction

I started studying development after finding an interest in it while idling at home, and I am currently in charge of platform server development in Pangyo. I am continuing my activities as a knowledge sharer because I want to provide you with the methods I used to study, as well as the various problems and solutions you may encounter in practice.

 

These lectures are not created solely through my own knowledge. Every lecture is made together with others.

 

Instructor Experience

[Former] Blockchain developer related to Sandbox IP

[Former] Metaverse Backend Developer

[Current] A veteran server developer in Pangyo

 

Interview History

Other Inquiries

  • unduck2022@gmail.com

More

Curriculum

All

28 lectures ∙ (4hr 55min)

Course Materials:

Lecture resources
Published: 
Last updated: 

Reviews

All

29 reviews

4.9

29 reviews

  • eightee724277님의 프로필 이미지
    eightee724277

    Reviews 6

    Average Rating 5.0

    5

    93% enrolled

    I learned so much. I think this is a great lecture. I'm planning to take other courses as well.

    • jhong
      Instructor

      Hello, I'm glad you liked #8!! I hope to see you in other lectures too 😊😊 Thank you for the good review!

  • youngba8935643님의 프로필 이미지
    youngba8935643

    Reviews 7

    Average Rating 5.0

    Edited

    5

    96% enrolled

    I prepared for employment and referred to the instructor's lectures a lot while working in practice, using them as a foundation for my learning, and I think this is really high-quality content that has been tremendously helpful. The process of writing code together is also very beneficial, and since it feels like coding alongside someone right next to me, I think the learning effect becomes that much better!! I hope to watch more frequently in the future and that good lectures will continue to be created. Thank you!

    • jhong
      Instructor

      Hello Tenburger! I heard you're preparing for job hunting!! I hope this course will be of great help to you. Please let us know if you successfully land a job later 😊😊 Thank you!

  • kask814587762님의 프로필 이미지
    kask814587762

    Reviews 3

    Average Rating 5.0

    5

    100% enrolled

    I enjoyed the lecture. There wasn't any major inconvenience in watching it, and the content itself was very beneficial. Please continue to provide good lectures in the future!

    • jhong
      Instructor

      Hello Woo-dang-tang! Thank you so much for leaving such a nice review!! I will work hard to provide even more beneficial and interesting lectures that are suitable for practical work in the future! Have a great day!

  • tasdo4797187님의 프로필 이미지
    tasdo4797187

    Reviews 5

    Average Rating 5.0

    5

    100% enrolled

    As a backend developer... this was really helpful. Thank you.

    • jhong
      Instructor

      Hello tasd os! Since we're in the same field, I'm so proud that it seems to have been very helpful to you. Thank you!

  • kju626095386님의 프로필 이미지
    kju626095386

    Reviews 8

    Average Rating 5.0

    5

    100% enrolled

    I watched the lecture well with realistic and good content. Thank you.

    • jhong
      Instructor

      Hello ks ju, thank you for leaving a review. In actual operating environments, this structure can accommodate much more diverse functionality, so you can think of it as a structure designed for that purpose 😊😊 I will continue to provide more beneficial lectures in the future. Have a great day :)

Hong's other courses

Check out other courses by the instructor!

Similar courses

Explore other courses in the same field!

$63.80