0Pricing
Erlang OTP: Distributed & Fault-Tolerant Systems Programming · 강의

기본 동시성 패턴

프로세스 생성과 메시지 수신을 사용하여 간단한 동시성 애플리케이션을 구현하고 클라이언트-서버 상호 작용과 같은 기본 패턴을 살펴봅니다.

기본 동시성 패턴은(는) CoddyKit의 무료 Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Erlang OTP: Distributed & Fault-Tolerant Systems Programming 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Concurrency Patterns in Erlang

Concurrency patterns are proven ways to structure how processes interact, so you build robust, predictable concurrent apps.

The Request-Response Pattern

The Request-Response pattern is a conversation: a client sends a request, the server does the work, then replies. The backbone of interactive services.

Building a Simple Server

A server process loops on receive, handling each message and replying with SenderPid ! Reply; self() gives it its own PID.

Code: Echo Server Example

This echo server receives any message, grabs the sender's PID, and sends the message right back tagged as echoed.

-module(echo_server).
-export([start/0, loop/0]).

start() ->
    spawn(echo_server, loop, []).

loop() ->
    receive
        {FromPid, Message} ->
            FromPid ! {self(), echoed, Message},
            loop();
        _ ->
            io:format("Server received unknown message.~n"),
            loop()
    end.

Code: Echo Client Interaction

The matching echo client spawns the server, sends {self(), msg} so the server knows where to reply, then waits for the response.

-module(echo_client).
-export([run/0]).

run() ->
    ServerPid = echo_server:start(),
    io:format("Server started with PID: ~p~n", [ServerPid]),

    Request = "Hello Erlang!",
    ServerPid ! {self(), Request},
    io:format("Client sent: ~p to server ~p~n", [Request, ServerPid]),

    receive
        {_ServerPid, echoed, Response} ->
            io:format("Client received reply: ~p~n", [Response]);
        _ ->
            io:format("Client received unexpected message.~n")
    after 5000 ->
        io:format("Client timed out waiting for reply.~n")
    end.

Running the Echo System

To run it, compile both modules and call echo_client:run() in the shell — a full request-response cycle across two processes.

The Asynchronous Pattern

The Asynchronous ("fire and forget") pattern: the client sends a message and moves on immediately while the receiver works in the background. Great for logging or jobs.

Code: Asynchronous Logger Process

This logger process just receives messages and prints them, sending no reply — the server side of the asynchronous pattern.

-module(async_logger).
-export([start/0, loop/0]).

start() ->
    spawn(async_logger, loop, []).

loop() ->
    receive
        {log, Message} ->
            io:format("LOG: ~p~n", [Message]),
            loop();
        _ ->
            io:format("Logger received unknown message.~n"),
            loop()
    end.

Code: Asynchronous Logger Client

The matching client spawns the logger, sends a message, and continues immediately without waiting — non-blocking by design.

-module(logger_client).
-export([run/0]).

run() ->
    LoggerPid = async_logger:start(),
    io:format("Logger started with PID: ~p~n", [LoggerPid]),

    LoggerPid ! {log, "User X logged in."},
    io:format("Client sent first log. Continuing...~n"),

    timer:sleep(10), % Give logger a moment to process
    LoggerPid ! {log, "User Y viewed profile."},
    io:format("Client sent second log. Task complete.~n").

Concurrency Pattern Check

You're building a system where a user uploads a large video. Your main process needs to immediately tell the user "Video uploaded, processing in background." while a separate process transcodes the video. What pattern best describes the interaction between the main process and the video transcoder?

Recap: Basic Concurrency Patterns

Recap: Request-Response waits for a reply (interactive work), while Asynchronous fires and forgets (background tasks). Your core concurrency toolkit.

자주 묻는 질문

“기본 동시성 패턴” 강의는 무료인가요?

네 — “기본 동시성 패턴” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의 전체를 잠금 해제할 수 있습니다. Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의에는 총 4개의 강의가 포함되어 있습니다.

“기본 동시성 패턴”에서 뭘 배우나요?

프로세스 생성과 메시지 수신을 사용하여 간단한 동시성 애플리케이션을 구현하고 클라이언트-서버 상호 작용과 같은 기본 패턴을 살펴봅니다. 브라우저에서 직접 실행하는 실습 코드로 Erlang OTP: Distributed & Fault-Tolerant Systems Programming을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Erlang OTP: Distributed & Fault-Tolerant Systems Programming을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Erlang OTP: Distributed & Fault-Tolerant Systems Programming은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.

“기본 동시성 패턴” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Erlang 및 VM 소개
  2. Erlang 프로세스 및 메시징
  3. 기본 동시성 패턴
  4. 패턴 매칭과 가드
← Erlang OTP: Distributed & Fault-Tolerant Systems Programming(으)로 돌아가기