Skip to content

Commit 391b622

Browse files
committed
Merge branch 'development'
2 parents 53967e3 + 578b6c0 commit 391b622

File tree

6 files changed

+84
-24
lines changed

6 files changed

+84
-24
lines changed

infrastructure/Pulumi.production.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
config:
22
aws:region: ap-northeast-2
33
velog:DOCKER_ENV: production
4-
velog:target: server
4+
velog:target: cron

infrastructure/Pulumi.stage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
config:
22
aws:region: ap-northeast-2
33
velog:DOCKER_ENV: stage
4-
velog:target: server
4+
velog:target: server,web

infrastructure/src/common/ecs.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export const createECSfargateService = ({
4040
subnets: subnetIds,
4141
},
4242
taskDefinitionArgs: {
43+
cpu: option.taskCpu,
44+
memory: option.taskMemory,
4345
executionRole: {
4446
roleArn: ecsTaskExecutionRole.arn,
4547
},

infrastructure/src/lib/ecsOptions.ts

Lines changed: 72 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,91 @@
11
import { ENV } from '../env'
22

3-
const webEcsOption: EcsOption = {
4-
desiredCount: ENV.isProduction ? 2 : 1,
5-
containerCpu: ENV.isProduction ? 1024 : 512,
6-
containerMemory: ENV.isProduction ? 2048 : 1024,
3+
// fargate cpu memory combination
4+
// See: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html
5+
// 0.25 vCPU : 0.5 GB ~ 2 GB
6+
// 0.5 vCPU : 1 GB ~ 4 GB
7+
// 1 vCPU : 2 GB ~ 8 GB
8+
// 2 vCPU : 4 GB ~ 16 GB
9+
// 4 vCPU : 8 GB ~ 30 GB
10+
11+
const webProdEcsOption: EcsBaseOption = {
12+
desiredCount: 2,
13+
cpu: 1, // unit 1024
14+
memory: 2, // unit 1024
15+
maxCapacity: 12,
16+
minCapacity: 2,
17+
}
18+
19+
const webStageEcsOption: EcsBaseOption = {
20+
desiredCount: 1,
21+
cpu: 0.5, // unit 1024
22+
memory: 1, // unit 1024
723
maxCapacity: 12,
8-
minCapacity: ENV.isProduction ? 2 : 1,
24+
minCapacity: 1,
925
}
1026

11-
const serverEcsOption: EcsOption = {
12-
desiredCount: ENV.isProduction ? 2 : 1,
13-
containerCpu: ENV.isProduction ? 1024 : 512,
14-
containerMemory: 1024,
27+
const serverProdEcsOption: EcsBaseOption = {
28+
desiredCount: 2,
29+
cpu: 0.5, // unit 1024
30+
memory: 1, // unit 1024
1531
maxCapacity: 12,
16-
minCapacity: ENV.isProduction ? 2 : 1,
32+
minCapacity: 2,
1733
}
1834

19-
const cronEcsOption: EcsOption = {
20-
desiredCount: ENV.isProduction ? 1 : 0,
21-
containerCpu: ENV.isProduction ? 1024 : 512,
22-
containerMemory: 1024,
35+
const serverStageEcsOption: EcsBaseOption = {
36+
desiredCount: 1,
37+
cpu: 0.25, // unit 1024
38+
memory: 1, // unit 1024
39+
maxCapacity: 12,
40+
minCapacity: 1,
41+
}
42+
43+
const cronProdEcsOption: EcsBaseOption = {
44+
desiredCount: 1,
45+
cpu: 1, // unit 1024
46+
memory: 2, // unit 1024
2347
maxCapacity: 1,
24-
minCapacity: ENV.isProduction ? 1 : 0,
48+
minCapacity: 1,
49+
}
50+
51+
const cronStageEcsOption: EcsBaseOption = {
52+
desiredCount: 0,
53+
cpu: 0.25, // unit 1024
54+
memory: 0.5, // unit 1024
55+
maxCapacity: 0,
56+
minCapacity: 0,
2557
}
2658

2759
export const ecsOption = {
28-
web: webEcsOption,
29-
server: serverEcsOption,
30-
cron: cronEcsOption,
60+
web: generateEcsOption(ENV.isProduction ? webProdEcsOption : webStageEcsOption),
61+
server: generateEcsOption(ENV.isProduction ? serverProdEcsOption : serverStageEcsOption),
62+
cron: generateEcsOption(ENV.isProduction ? cronProdEcsOption : cronStageEcsOption),
63+
}
64+
65+
function generateEcsOption(option: EcsBaseOption): EcsOption {
66+
return {
67+
desiredCount: option.desiredCount,
68+
taskCpu: `${option.cpu} vCPU`,
69+
taskMemory: `${option.memory} GB`,
70+
containerCpu: 1024 * option.cpu,
71+
containerMemory: 1024 * option.memory,
72+
maxCapacity: option.maxCapacity,
73+
minCapacity: option.minCapacity,
74+
}
75+
}
76+
77+
type EcsBaseOption = {
78+
desiredCount: number
79+
cpu: number
80+
memory: number
81+
maxCapacity: number
82+
minCapacity: number
3183
}
3284

3385
type EcsOption = {
3486
desiredCount: number
87+
taskCpu: string
88+
taskMemory: string
3589
containerCpu: number
3690
containerMemory: number
3791
maxCapacity: number

packages/velog-cron/src/services/PostService/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,14 @@ export class PostService implements Service {
273273
}
274274

275275
const notAlphanumbericKorean = replaced.replace(/[a-zA-Z-0-9]/g, '') // remove korean
276-
if (notAlphanumbericKorean.length / replaced.length > 0.35) {
276+
if (notAlphanumbericKorean.length / replaced.length > 0.3) {
277277
score++
278278
}
279279

280+
if (!isForeign) {
281+
score--
282+
}
283+
280284
const initScore = score
281285
const usedBannedAltKeywords: string[] = []
282286
for (const { value: keyword } of bannedAltKeywords) {
@@ -295,10 +299,10 @@ export class PostService implements Service {
295299
}
296300
}
297301

298-
if (score >= 3) {
302+
if (score >= 4) {
299303
return {
300304
isSpam: true,
301-
reason: `initScore: ${initScore}, foreign, ${'bannedAltKeywords: '.concat(
305+
reason: `initScore: ${initScore}, ${'bannedAltKeywords: '.concat(
302306
usedBannedAltKeywords.join(','),
303307
)}`,
304308
}

packages/velog-web/src/features/home/components/HomeTab/HomeTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function HomeTab({ isFloatingHeader = false }: Props) {
6060
<motion.div
6161
initial={false}
6262
animate={{
63-
left: isFeed ? '68.33%' : isRecent ? '38.33%' : '2%',
63+
left: isFeed ? '70.33%' : isRecent ? '38.33%' : '2%',
6464
}}
6565
className={cx('indicator')}
6666
/>

0 commit comments

Comments
 (0)