Skip to content

Commit

Permalink
fixed file path for instructions, updated code sample (#98)
Browse files Browse the repository at this point in the history
Co-authored-by: Maish Saidel-Keesing
  • Loading branch information
maishsk authored Feb 21, 2023
1 parent dcb4683 commit 6f0b89a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions content/microservices/nodejs/tabs/cdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ awslogs get -G -S --timestamp --start 1m --watch $log_group

{{%expand "Expand here to see the solution" %}}

- To manually scale the service up, we simply will modify the code in `app.py` and change the desired count from 1 to 3
- To manually scale the service up, we simply will modify the code in `~/environment/ecsdemo-nodejs/cdk/cdk/nodejsservice.py` and change the desired count from 1 to 3

```python
fargate_service = aws_ecs.FargateService(
Expand Down Expand Up @@ -228,25 +228,26 @@ cdk deploy

#### Setup Autoscaling in the code

- Using the editor of your choice, open '~/environment/ecsdemo-nodejs/cdk/app.py' in the cdk directory.
- Using the editor of your choice, open `~/environment/ecsdemo-nodejs/cdk/cdk/nodejsservice.py` in the cdk directory.

- Search for `Enable Service Autoscaling` to find the code that will enable autoscaling for the service.

- Remove the comments (#) from the code for self.autoscale and below, once you remove them, it should look like the following:

```python
# Enable Service Autoscaling
self.autoscale = self.fargate_service.auto_scale_task_count(
min_capacity=1,
autoscale = fargate_service.auto_scale_task_count(
min_capacity=3,
max_capacity=10
)

self.autoscale.scale_on_cpu_utilization(
autoscale.scale_on_cpu_utilization(
"CPUAutoscaling",
target_utilization_percent=50,
scale_in_cooldown=core.Duration.seconds(30),
scale_out_cooldown=core.Duration.seconds(30)
scale_in_cooldown=Duration.seconds(30),
scale_out_cooldown=Duration.seconds(30)
)
self.autoscale = autoscale

```

Expand Down

0 comments on commit 6f0b89a

Please sign in to comment.