Skip to content

Commit

Permalink
✅ Test: 부하테스트 설정 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
HA0N1 committed Aug 2, 2024
1 parent f577448 commit 4c9837f
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 51 deletions.
36 changes: 36 additions & 0 deletions config/artillery.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# config:
# target: 'http://localhost:8080'
# phases:
# - duration: 60
# arrivalRate: 10
# - duration: 120
# arrivalRate: 20
# - duration: 180
# arrivalRate: 30

# scenarios:
# - flow:
# - get:
# url: '/posts/test'
# qs:
# page: '{{ $randomNumber(1,5) }}'
# headers:
# Accept: 'application/json'
config:
target: 'http://localhost:8080'
phases:
- duration: 60
arrivalRate: 10
- duration: 120
arrivalRate: 20
- duration: 180
arrivalRate: 30

scenarios:
- flow:
- get:
url: '/posts/optimized-test' # 최적화된 엔드포인트
qs:
page: '{{ $randomNumber(1,5) }}'
headers:
Accept: 'application/json'
2 changes: 1 addition & 1 deletion config/prometheus-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ scrape_configs:
- job_name: 'prometheus'
scrape_interval: 1m
static_configs:
- targets: ['localhost:9090']
- targets: ['prometheus:9090']

- job_name: 'node'
static_configs:
Expand Down
7 changes: 4 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
TZ: Asia/Seoul
networks:
- loki

Expand Down Expand Up @@ -58,8 +59,8 @@ services:
- ./grafana-data:/var/lib/grafana
restart: always
environment:
- GF_SECURITY_ADMIN_USER=${GF_USER}
- GF_SECURITY_ADMIN_PASSWORD=${GF_PASSWORD}
GF_SECURITY_ADMIN_USER: ${GF_USER}
GF_SECURITY_ADMIN_PASSWORD: ${GF_PASSWORD}
env_file:
- .env
networks:
Expand Down Expand Up @@ -97,7 +98,7 @@ services:
- loki

postgres_exporter:
image: wrouesnel/postgres_exporter:latest
image: bitnami/postgres-exporter:latest
container_name: postgres-exporter
environment:
DATA_SOURCE_NAME: 'postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres/${POSTGRES_DB}?sslmode=disable'
Expand Down
144 changes: 110 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.583.0",
"@nestjs/axios": "^3.0.2",
"@nestjs/cache-manager": "^2.2.2",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.2.2",
"@nestjs/core": "^10.0.0",
Expand All @@ -43,6 +44,8 @@
"aws-sdk": "^2.1628.0",
"bcrypt": "^5.1.1",
"body-parser": "^1.20.2",
"cache-manager": "^5.7.4",
"cache-manager-redis-yet": "^5.1.3",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"cookie-parser": "^1.4.6",
Expand Down
10 changes: 0 additions & 10 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,6 @@ const typeOrmModuleOptions = {
ChatModule,
RedisModule,
NewsModule,
ClientsModule.register([
{
name: 'REDIS_SERVICE',
transport: Transport.REDIS,
options: {
host: 'localhost',
port: 6379,
},
},
]),
NotificationModule,
],
providers: [AppService],
Expand Down
13 changes: 13 additions & 0 deletions src/post/post.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Query,
ValidationPipe,
UseInterceptors,
Inject,
} from '@nestjs/common';
import { PostService } from './post.service';
import { CreatePostDto } from './dto/create-post.dto';
Expand All @@ -26,7 +27,19 @@ export class PostController {
private readonly postService: PostService,
private readonly s3Service: S3Service,
) {}
@Get('/test')
async search(@Query('page') page: number = 1) {
// const posts = await this.postService.posts(page);
const posts = await this.postService.posts();

return posts;
}
@Get('/optimized-test')
async optimizedSearch(@Query('page') page: number = 1) {
const posts = await this.postService.optimizedPosts(page);

return posts;
}
// region별 조회
@Get('/region/:regionId')
@ApiParam({ type: 'number', name: 'regionId', example: 1 })
Expand Down
2 changes: 2 additions & 0 deletions src/post/post.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ import { UserModule } from 'src/user/user.module';
import { DetectiveOffice } from 'src/office/entities/detective-office.entity';
import { JwtModule } from '@nestjs/jwt';
import { File } from 'src/s3/entities/s3.entity';
import { RedisModule } from 'src/redis/redis.module';

@Module({
imports: [
S3Module,
AuthModule,
UserModule,
RedisModule,
TypeOrmModule.forFeature([
DetectivePost,
Region,
Expand Down
Loading

0 comments on commit 4c9837f

Please sign in to comment.