Server์ ๊ธฐ๋ณธ ๊ฐ๋
์น ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ง๋ค๊ณ ์ด์ํ๊ธฐ ์ํด์๋ Web Server์ Application Server์ ์ฐจ์ด๋ฅผ ์ดํดํ๋ ๊ฒ์ด ์ค์ํ๋ค. ์ฝ๊ฒ ๋น์ ํ์๋ฉด:
- Web Server๋ ์์์ ์ ํ ์๋ฒ์ ๊ฐ๋ค (์ฃผ๋ฌธ ์ ์, ์์ ์๋น)
- Application Server๋ ์ฃผ๋ฐฉ ์ ฐํ์ ๊ฐ๋ค (์ค์ ์์ ์กฐ๋ฆฌ)
Web Server ์ดํดํ๊ธฐ
๊ธฐ๋ณธ ์ญํ
Web server๋ client(์น ๋ธ๋ผ์ฐ์ )์ ์์ฒญ์ ๊ฐ์ฅ ๋จผ์ ๋ฐ์๋ค์ด๋ ๊ด๋ฌธ์ด๋ค.
graph LR Browser[๋ธ๋ผ์ฐ์ ] -->|HTTP Request| WebServer[Web Server] WebServer -->|HTTP Response| Browser
Static content ์ฒ๋ฆฌ
# Nginx static file ์ค์ ์์
location /images/ {
root /var/www/static; # ์ค์ ํ์ผ ์์น
expires 30d; # ๋ธ๋ผ์ฐ์ ์บ์ฑ ์ค์
}์๋ชป๋ ์์์ ์ฌ๋ฐ๋ฅธ ์์
์๋ชป๋ ๊ตฌ์ฑ:
# ์๋ชป๋ ์์ - ๋ชจ๋ ์์ฒญ์ Application Server๋ก ์ ๋ฌ
location / {
proxy_pass http://app_server;
}์ฌ๋ฐ๋ฅธ ๊ตฌ์ฑ:
# ์ฌ๋ฐ๋ฅธ ์์ - static file์ Web Server๊ฐ ์ง์ ์ฒ๋ฆฌ
location /static/ {
root /var/www;
}
location / {
proxy_pass http://app_server;
}Application Server ์ดํดํ๊ธฐ
๊ธฐ๋ณธ ์ญํ
Application server๋ business logic์ ์คํํ๊ณ ๋์ ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ๋ค.
Database ์ฐ๋ ์์
# Application Server์์์ ๋์ ์ฒ๋ฆฌ ์์
@app.route('/users')
def get_users():
users = database.query("SELECT * FROM users")
return generate_response(users)Server ๊ฐ ํต์
sequenceDiagram Browser->>Web Server: HTTP Request Web Server->>Application Server: Forward Request Application Server->>Database: Query Data Database->>Application Server: Return Data Application Server->>Web Server: Process & Return Web Server->>Browser: HTTP Response
์ค์ ์ฌ์ฉ ์ฌ๋ก
1. Blog ์๋น์ค ๊ตฌ์ฑ
-
Web Server (Nginx)
- ์ด๋ฏธ์ง, CSS, JS ํ์ผ ์๋น
- SSL/TLS ์ฒ๋ฆฌ
- Caching ์ค์
-
Application Server (Django)
- ๊ฒ์๊ธ CRUD ์ฒ๋ฆฌ
- ์ฌ์ฉ์ ์ธ์ฆ
- ๋๊ธ ์์คํ
2. E-commerce ์์คํ
-
Web Server (Apache)
- Product ์ด๋ฏธ์ง ์๋น
- Security header ์ค์
- Load balancing
-
Application Server (Spring Boot)
- ์ํ ๊ฒ์/ํํฐ๋ง
- ์ฅ๋ฐ๊ตฌ๋ ๊ด๋ฆฌ
- ๊ฒฐ์ ์ฒ๋ฆฌ
Performance ๊ณ ๋ ค์ฌํญ
1. Caching ์ ๋ต
# Web Server caching ์ค์
location /static/ {
expires 1h;
add_header Cache-Control "public";
}2. Load Balancing
# Load balancing ์ค์
upstream app_servers {
server app1:8000;
server app2:8000;
server app3:8000;
}์ฃผ์์ฌํญ
Security ๊ด๋ จ
-
Web Server
- ์ธ๋ถ ์ ๊ทผ ์ ํ
- SSL/TLS ์ค์
- Security header ์ค์
-
Application Server
- ๋ด๋ถ ๋คํธ์ํฌ์๋ง ๋ ธ์ถ
- ์ ๊ทผ ๊ถํ ์ต์ํ
- ๋ฏผ๊ฐ ์ ๋ณด ์ํธํ
๊ฐ๋ฐ ํ๊ฒฝ ์ค์
๊ธฐ๋ณธ ๊ฐ๋ฐ ํ๊ฒฝ
# ๊ฐ๋ฐ์ฉ Web Server ์ค์
python -m http.server 8000 # ๊ฐ๋จํ static file ์๋ฒ
# ๊ฐ๋ฐ์ฉ Application Server ์คํ
python manage.py runserver # Django ๊ฐ๋ฐ ์๋ฒ๋ฐฐํฌ ์ ๊ณ ๋ ค์ฌํญ
Checklist
-
Security
- SSL/TLS ์ค์ ํ์ธ
- ๋ฐฉํ๋ฒฝ ๊ท์น ๊ฒํ
- ์ ๊ทผ ๊ถํ ์ค์
-
Performance
- Caching ์ค์
- Resource limit ์ค์
- Monitoring ๊ตฌ์ฑ
๊ฒฐ๋ก
Web Server์ Application Server๋ ๊ฐ๊ฐ์ ์ญํ ์ด ๋ช ํํ๋ค:
- Web Server: Front-end ์์ฒญ ์ฒ๋ฆฌ, ๋ณด์, static content ๊ด๋ฆฌ
- Application Server: Business logic ์ฒ๋ฆฌ, ๋ฐ์ดํฐ ๊ด๋ฆฌ, ๋์ ์ปจํ ์ธ ์์ฑ
ํจ์จ์ ์ธ ์น ์๋น์ค๋ฅผ ์ํด์๋ ๋ ์๋ฒ์ ํน์ฑ์ ์ดํดํ๊ณ ์ ์ ํ ๊ตฌ์ฑํ๋ ๊ฒ์ด ์ค์ํ๋ค.