AWS

AWS User Group Berlin @ Foodpanda

AWS User Group Berlin @ Foodpanda

We strongly believe that is important to keep up to date in our tech stack and be close to the tech community. Therefore foodpanda hosted the AWS User Group Berlin edition of November 2016. Continue reading →

Posted by Vitor on 16 Nov 2016 in AWS, Conferences
Scaling docker clusters using AWS ECS

Scaling docker clusters using AWS ECS

As many people these days at foodpanda we are also moving towards microservices approach using docker containers. Docker allows to run applications in an isolated way, wherever you need. However, running many of them is hard to scale and deploy. Did you already hear about Elastic Container Service (ECS) by Amazon Web Services ? after reading this article you should have basic knowledge about what this service can offer to you. Last but not least, I am also comparing it with kubernetes.

Some History

Microservice is for some time already, one of these cool words any IT developer wants to hear in a conference or in a job interview. Microservices wouldn’t be the same without docker and also docker wouldn’t be the same without a tool to manage its containers. Some of these container tools are kubernetes and ECS by AWS.

At foodpanda, ECS was a product which became more interesting when the new application Load Balancer (ELB) was released. This new ELB allows to route traffic on dynamic ports inside EC2 instances. In the past, the classic load balancer was only able to route traffic to the same port on all the instances of the Auto Scaling Group (ASG).

So, “what has to do with ECS?” This new load balancer is able to route traffic to different ports exposed by multiple containers running for same service inside an instance. This Application Load Balancer not only reduces the chances of wasting resources but also increases the speed of scaling up your application (if no boot time required).

The following picture shows now how multiple containers for same purpose (service) can be running and scaled inside same ec2 instance.

elastic container service cluster

ECS Components

In a nutshell these are the components of ECS:

  • ECS agent:
    • Daemon by amazon used for connecting instances to a cluster.
    • If installed, ec2 automatically is attached to default cluster.
  • Task Definition:
    • Describes the container(s), volume(s)… of an ECS Service. Task definitions have revisions.
    • A Task definition should group containers which share common purpose.
    • Task definitions can only have up to 10 container definitions.
  • Service:
    • Used for configuring the amount of tasks definitions desired to be running.
    • Defines the scaling and deployment rules for the tasks definitions.
    • Used by the ECS Scheduler in order to have the amount of healthy task definitions running.
  • Service Scheduler:
    • Internal service by amazon (hidden for aws users or apis) for managing the cluster.
  • Cluster:
    • It simply holds the elements above.
    • Clusters can contain multiple different container instance types.
    • Clusters are region-specific.
    • Container instances can only be a part of one cluster at a time.

ecs components

Deployment

ECS is fully supported by both api and cli so you can easily integrate the deployment of new task definitions (container images) inside your CI tool.

Don’t worry if by mistake you deploy a broken release, ECS scheduler uses the ELB health check in order to evaluate whether the task definition you are trying to deploy is healthy enough or not. In case it fails, ECS schedulers stops the deployment.

ecs deployment diagram

Scaling

ECS scheduler only scales the amount of task definitions, so it only starts/stops containers from a limited amount of instances running on your Auto Scaling Group (ASG). This means that you still have to configure instance scaling policies for that ASG. Luckily you can use ECS metrics such as “reserved_memory” or “reserved_cpu” in order to increase/reduce number of instances available in the cluster. On the other hand, ECS scheduler can scale not only based on classic metrics such as CPU consumed by your containers but also based on custom metrics such as messages available from a sqs queue.

ECS compared by Kubernetes (K8s) v1.4.6 (latest stable release)

The following table shows what ECS can and cannot do compared by another cluster manager called kubernetes. Notice that it does not try to show what both can do:

Feature ECS K8s
Service discovery
Secret/Config management
Custom metric service scaling (containers)
Instance (server) scaling based on cluster metrics
Requires extra instance for cluster management
Can run on dev env
Requires extra host for Service Load Balancer

To me, both have its pros and cons so it is up to project requirements which one to use. However, if your infra is really tied to aws services, ECS is probably the best option since you might run yourself the missing services.

References

Posted by Vicente on 14 Nov 2016 in AWS, DevOps
Run ML predictions with R on AWS Lambda

Run ML predictions with R on AWS Lambda

In this article, I will introduce how and why our team here at foodpanda is exposing an API that makes machine learning predictions using R, AWS Lambda and Amazon API Gateway. I will guide you through all the required steps while using the prediction of the food preparation time of our restaurants. Continue reading →

Posted by Giuliano on 10 Nov 2016 in AWS
CloudFormation @ foodpanda

CloudFormation @ foodpanda

CloudFormation is a declarative and flexible language in JSON format that describes your AWS infrastructure. You can enumerate what AWS resources, configuration values and interconnections you need in a template and then let AWS Cloudformation do the rest. Continue reading →

Posted by Jens on 12 Jan 2016 in AWS, DevOps