0Pricing
API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) · 강의

상태 확인 및 서버 모니터링

상태 확인을 구현하여 상태가 좋지 않은 백엔드 서버를 부하 분산 풀에서 자동으로 제거해 보세요.

상태 확인 및 서버 모니터링은(는) CoddyKit의 무료 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에는 총 4개의 강의가 포함되어 있습니다.

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

Keeping Servers Healthy

Imagine a busy restaurant with multiple chefs. If one chef gets sick, you don't want to send orders to them, right?

In load balancing, health checks do exactly that. They constantly monitor backend servers to ensure they are ready to handle requests.

Why Health Checks Matter

Without health checks, a load balancer might keep sending requests to a server that is down, overloaded, or unresponsive.

  • Bad User Experience: Users get errors instead of content.
  • Wasted Resources: The load balancer tries to connect to a dead end.
  • Cascading Failures: Overloads can spread if requests aren't redirected.

Nginx's Health Check Basics

Nginx provides built-in directives within its upstream block to perform passive health checks. These checks react to failed connection attempts or responses.

The two main directives are max_fails and fail_timeout.

`max_fails`: Failed Attempts

The max_fails directive sets the number of consecutive failed attempts after which Nginx considers a server "unhealthy".

  • Default: 1 (one failure marks it unhealthy).
  • `max_fails=0`: Disables health checks for that server.
  • A "failure" can be a connection error, timeout, or specific HTTP status codes (like 5xx) if configured.

`fail_timeout`: Recovery Time

Once a server is marked unhealthy, Nginx will stop sending requests to it for a duration specified by fail_timeout.

  • Default: 10s (10 seconds).
  • After this timeout, Nginx will tentatively send a request to the server to check if it has recovered.
  • This prevents hammering a down server.

Implementing Nginx Health Checks

Let's see how to configure max_fails and fail_timeout in an Nginx upstream block. Here, we define two backend servers.

http {
    upstream backend_servers {
        server 192.168.1.100:8080 max_fails=3 fail_timeout=15s;
        server 192.168.1.101:8080 max_fails=3 fail_timeout=15s;
    }

    server {
        listen 80;
        location / {
            proxy_pass http://backend_servers;
        }
    }
}

Nginx's Server Management

When a server hits its max_fails limit within the fail_timeout period, Nginx temporarily removes it from the load balancing pool.

  • Requests are then distributed among the remaining healthy servers.
  • After fail_timeout expires, Nginx tries sending a single request to the "unhealthy" server. If it succeeds, the server is marked healthy again.

Observing Server Health

While Nginx's basic health checks are passive, you can observe their effects in Nginx logs.

Error logs will show messages when a server is marked down or up. For more advanced, active monitoring and a dashboard, Nginx Plus offers dedicated features, but that's beyond basic Nginx.

Health Check Tips

Properly configuring health checks is key for reliable systems:

  • Tune Values: Adjust max_fails and fail_timeout based on your application's responsiveness and recovery time.
  • Backend Readiness: Ensure your backend applications have a dedicated health endpoint (e.g., /health) that reports true service readiness.
  • Combine with Monitoring: Use external monitoring tools to alert you when Nginx marks servers down.

Quick Check on Health Checks

You've configured an Nginx upstream server with max_fails=2 and fail_timeout=30s. If the server fails 3 consecutive requests, what happens next?

Health Check Recap

In this lesson, we learned about Nginx's essential health check directives:

  • max_fails: The number of failed attempts before a server is marked unhealthy.
  • fail_timeout: The period for which an unhealthy server is taken out of the load balancing pool.
  • These passive checks are crucial for maintaining backend reliability and improving user experience.

자주 묻는 질문

“상태 확인 및 서버 모니터링” 강의는 무료인가요?

네 — “상태 확인 및 서버 모니터링” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의 전체를 잠금 해제할 수 있습니다. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에는 총 4개의 강의가 포함되어 있습니다.

“상태 확인 및 서버 모니터링”에서 뭘 배우나요?

상태 확인을 구현하여 상태가 좋지 않은 백엔드 서버를 부하 분산 풀에서 자동으로 제거해 보세요. 브라우저에서 직접 실행하는 실습 코드로 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“상태 확인 및 서버 모니터링” 강의는 얼마나 걸리나요?

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

이 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 부하 분산 알고리즘
  2. 상태 확인 및 서버 모니터링
  3. 고정 세션 및 세션 지속성
  4. 가중치 기반 로드 밸런싱 및 백업 서버
← API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)(으)로 돌아가기