Skip to content

Commit c4e92aa

Browse files
authored
Merge pull request #93 from codeit-monew/feature/#86
[feat] 부하테스트 진행
2 parents 4e3518c + cafce24 commit c4e92aa

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

monew/docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ services:
1818
test: ["CMD-SHELL", "pg_isready -U postgres"]
1919
interval: 5s
2020
retries: 5
21+
deploy:
22+
resources:
23+
limits:
24+
cpus: "4.0"
25+
memory: 2g
26+
reservations:
27+
cpus: "2.0"
28+
memory: 1g
2129

2230
redis:
2331
image: redis:7
@@ -26,6 +34,11 @@ services:
2634
- "6379:6379"
2735
networks:
2836
- monew-net
37+
deploy:
38+
resources:
39+
limits:
40+
cpus: "1.0"
41+
memory: 512m
2942

3043
mongo:
3144
image: mongo:6
@@ -36,6 +49,11 @@ services:
3649
- "27017:27017"
3750
networks:
3851
- monew-net
52+
deploy:
53+
resources:
54+
limits:
55+
cpus: "2.0"
56+
memory: 1g
3957

4058
app:
4159
build:
@@ -58,6 +76,8 @@ services:
5876
SPRING_DATA_REDIS_HOST: redis
5977
BATCH_TRIGGER_ENABLED: true
6078
SPRING_BATCH_JDBC_INITIALIZE_SCHEMA: always
79+
NAVER_CLIENT_ID: ${NAVER_CLIENT_ID}
80+
NAVER_CLIENT_SECRET: ${NAVER_CLIENT_SECRET}
6181
healthcheck:
6282
test: ["CMD-SHELL", "curl -f http://localhost:8080/actuator/health || exit 1"]
6383
interval: 10s

monew/src/main/java/com/spring/monew/auth/config/SecurityConfig.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.spring.monew.auth.config;
22

33
import lombok.RequiredArgsConstructor;
4+
import lombok.extern.slf4j.Slf4j;
45
import org.springframework.beans.factory.annotation.Value;
56
import org.springframework.context.annotation.Bean;
67
import org.springframework.context.annotation.Configuration;
@@ -14,6 +15,7 @@
1415
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
1516
import com.spring.monew.common.filter.RequestIdFilter;
1617

18+
@Slf4j
1719
@RequiredArgsConstructor
1820
@Configuration
1921
@EnableWebSecurity
@@ -22,20 +24,26 @@ public class SecurityConfig {
2224
private final HeaderAuthFilter headerAuthFilter;
2325
private final RequestIdFilter requestIdFilter;
2426

25-
@Value("${monitoring.prometheus.allow-ip}")
26-
private String prometheusAllowIp; // yml 속성 주입 (기본값은 localhost)
27+
@Value("${monitoring.prometheus.allow-ip:127.0.0.1}")
28+
private String prometheusAllowIp;
2729

2830
@Bean
2931
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
3032
http
31-
.csrf(AbstractHttpConfigurer::disable) // CSRF 보안 비활성화 (개발용)
32-
33+
.csrf(AbstractHttpConfigurer::disable)
3334
.authorizeHttpRequests(authorize -> authorize
3435
.requestMatchers("/actuator/prometheus")
3536
.access((authentication, context) -> {
3637
String remoteAddr = context.getRequest().getRemoteAddr();
37-
boolean equals = remoteAddr.equals(prometheusAllowIp);// Prometheus IP
38-
return new AuthorizationDecision(equals);
38+
boolean allowed =
39+
remoteAddr.equals("127.0.0.1") ||
40+
remoteAddr.equals("0:0:0:0:0:0:0:1") || // IPv6 localhost
41+
remoteAddr.equals("localhost") ||
42+
remoteAddr.startsWith("172.") || // Docker 내부 네트워크
43+
remoteAddr.startsWith("192.168.") ||
44+
remoteAddr.equals(prometheusAllowIp);
45+
46+
return new AuthorizationDecision(allowed);
3947
})
4048
.requestMatchers("/actuator/health", "/actuator/info",
4149
"/actuator/loggers").permitAll() //Actuator 허용 (원래는 이렇게 하면 안됨)
@@ -52,7 +60,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
5260
return http.build();
5361
}
5462

55-
5663
@Bean
5764
public PasswordEncoder passwordEncoder() {
5865
return new BCryptPasswordEncoder();

monew/src/main/resources/schema.sql

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ CREATE TABLE articles
9898
id UUID PRIMARY KEY,
9999
interest_id UUID NOT NULL,
100100
source VARCHAR(20) NOT NULL CHECK (source IN ('NAVER', 'HANKYUNG', 'CHOSUN', 'YEONHAP')),
101-
source_url VARCHAR(255) NOT NULL UNIQUE,
101+
source_url VARCHAR(500) NOT NULL UNIQUE,
102102
title VARCHAR(255) NOT NULL,
103103
publish_date TIMESTAMP WITH TIME ZONE NOT NULL,
104104
summary TEXT NOT NULL,
@@ -286,3 +286,12 @@ CREATE INDEX IF NOT EXISTS idx_notif_user_confirm_created_desc
286286
-- 정리 배치(삭제): WHERE confirmed=true AND updated_at < :threshold
287287
CREATE INDEX IF NOT EXISTS idx_notif_confirmed_updated
288288
ON notifications (confirmed, updated_at);
289+
290+
-- comments Indexing
291+
-- (1) createdAt 기반 정렬
292+
CREATE INDEX IF NOT EXISTS idx_comment_article_created
293+
ON comments (article_id, is_deleted, created_at DESC, id);
294+
295+
-- (2) likeCount 정렬 대비
296+
CREATE INDEX IF NOT EXISTS idx_comment_article_like
297+
ON comments (article_id, is_deleted, like_count DESC, created_at DESC, id);

0 commit comments

Comments
 (0)