Giter Club home page Giter Club logo

springboot-ecs-fargate's Introduction

Spring Boot + ECS + Fargate



Report Bug · Request Feature

Jean Jacques Barros Repository size GitHub last commit License GitHub Pull Requests Stargazers

Integration between Spring Boot and AWS Elastic Container Service (Fargate)

Config Docker

Build Image

docker build -t digimonapi:latest "."

Run Container using image created

docker run -d -p 80:80 -t digimonapi:latest

Cloudformation

Use file template.yml to create that resources:

  • Cluster
  • TaskDefinition
  • Service
  • Security Group
  • Load Balancer
  • CloudWatch
Service:
  Type: "AWS::ECS::Service"
  Properties:
    ServiceName: !Sub service-${FeatureName}-${MicroServiceName}
    <...>
    CapacityProviderStrategy:
      - CapacityProvider: FARGATE_SPOT
        Weight: 5
      - CapacityProvider: FARGATE
        Weight: 1
    <...>

AutoScaling

Config AutoScaling to scale up and down the service. Use template.yml to create that resources:

ScalableTarget:
  Type: AWS::ApplicationAutoScaling::ScalableTarget
  DependsOn: Service
  Properties:
    MinCapacity: 2
    MaxCapacity: 6
    ResourceId: !Join
      - "/"
      - - service
        - !Ref EcsClusterName
        - !GetAtt Service.Name
    RoleARN: !GetAtt AutoScalingRole.Arn
    ScalableDimension: ecs:service:DesiredCount
    ServiceNamespace: ecs

ScalingPolicy:
  Type: AWS::ApplicationAutoScaling::ScalingPolicy
  Properties:
    PolicyName: !Sub "${FeatureName}-auto-scaling-policy"
    PolicyType: TargetTrackingScaling
    ScalingTargetId: !Ref ScalableTarget
    TargetTrackingScalingPolicyConfiguration:
      PredefinedMetricSpecification:
        PredefinedMetricType: ECSServiceAverageCPUUtilization
      TargetValue: 30.0

It's configured to scale up and down the service when the CPU usage is greater than 30%.

Scheduled Scaling

Config Scheduled Scaling to scale up and down the service. Use template.yml to create that resources:

ScalableTarget:
  <...>
  ScheduledActions:
    - ScalableTargetAction:
        MinCapacity: 0
        MaxCapacity: 0
      Schedule: 'cron(0 0 22 ? * MON-FRI)'
      ScheduledActionName: scale-down
    - ScalableTargetAction:
        MinCapacity: 2
        MaxCapacity: 6
      Schedule: 'cron(0 0 11 ? * MON-FRI)'
      ScheduledActionName: scale-up

Articles

These are my articles about ECS Fargate using Spot instance and AutoScaling with ECS.

CodeBuild Notes

  • Add ECR permissions to codeBuild.
  • Error - "You have reached your pull rate limit"

Developed by Jean Jacques Barros

springboot-ecs-fargate's People

Contributors

jjeanjacques10 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.