Académique Documents
Professionnel Documents
Culture Documents
as CODE
/usr/bin/ruby1.9.1 extconf.rb
creating Makefile
make
sh: 1: make: not found
Ah, I just need to install make
> sudo apt-get install make
...
Success!
> gem install rails
> gem install rails
Fetching: nokogiri-1.6.7.2.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.0.0.rc2
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***
Hmm. Time to visit StackOverflow.
> sudo apt-get install zlib1g-dev
...
Success!
> gem install rails
> gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.0.0.rc2
checking for gzdopen() in -lz... yes
checking for iconv... yes
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
/usr/bin/ruby1.9.1 extconf.rb
Eventually you get it working
Now you urgently have to update
all your Rails installs
> bundle update rails
> bundle update rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.0.0.rc2
checking for gzdopen() in -lz... yes
checking for iconv... yes
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
ybrikman.com
Co-founder of
Gruntwork
gruntwork.io
We offer DevOps
as a Service
gruntwork.io
And DevOps
as a Library
gruntwork.io
PAST LIVES
Author of
Hello,
Startup
hello-startup.net
And
Terraform:
Up & Running
terraformupandrunning.com
Slides and code from this talk:
ybrikman.com/speaking
Outline
1. Microservices
2. Docker
3. Terraform
4. ECS
5. Recap
Outline
1. Microservices
2. Docker
3. Terraform
4. ECS
5. Recap
Code is the enemy: the more you
have, the slower you go
Project Size Bug Density
Lines of code Bugs per thousand lines
of code
< 2K 0 – 25
2K – 6K 0 – 40
64K – 512K 2 – 70
moduleE.func()
http://service.e
1. Isolation
2. Technology agnostic
3. Scalability
Disadvantages of services:
1. Operational overhead
2. Performance overhead
3. I/O, error handling
4. Backwards compatibility
5. Global changes, transactions,
referential integrity all very hard
For more info, see: Splitting Up a
Codebase into Microservices and
Artifacts
For this talk, we’ll use two
example microservices
require 'sinatra'
get "/" do
"Hello, World!"
end
Virtual Machine
Host OS
Hardware
Virtual Machine
Host OS
Hardware
Host OS Host OS
Hardware Hardware
Host OS Host OS
Hardware Hardware
real 0m0.183s
user 0m0.009s
sys 0m0.014s
EXPOSE 4567
CMD ["ruby", "app.rb"]
EXPOSE 4567
CMD ["ruby", "app.rb"]
(...)
(...)
EXPOSE 3000
CMD ["rails", "start"]
sinatra_backend:
image: brikis98/sinatra-backend
ports:
- "4567:4567"
sinatra_backend:
image: brikis98/sinatra-backend
ports:
- "4567:4567"
1. Maturity
2. Collaboration on Terraform state is
hard (but terragrunt makes it easier)
3. No rollback
4. Poor secrets management
Outline
1. Microservices
2. Docker
3. Terraform
4. ECS
5. Recap
EC2 Container Service (ECS) is a
way to run Docker on AWS
{
"name": "example", {
"image": "foo/example", "cluster": "example",
"cpu": 1024, "serviceName": ”foo",
"memory": 2048, "taskDefinition": "",
"essential": true, "desiredCount": 2
} ECS Agent
}
ECS Tasks
ECS Scheduler
ECS Task Definition ECS Service Definition
EC2 Instance
ECS Cluster
ECS Overview
EC2 Instance
ECS Cluster
EC2 Instance
ECS Cluster
ECS Cluster
ECS Cluster
ECS Tasks
ECS Scheduler
ECS Task Definition ECS Service Definition
EC2 Instance
ECS Cluster
ECS Tasks
ECS Scheduler
ECS Task Definition ECS Service Definition
EC2 Instance
ECS Cluster
ECS Tasks
User
EC2 Instance
ECS Cluster
ECS Tasks
User
EC2 Instance
ECS Cluster
v1
ECS Agent
v1 v2
EC2 Instance
ECS Cluster
ECS Tasks
EC2 Instance
ECS Cluster
ECS Tasks
ECS Cluster
ECS Tasks
ECS Cluster
ECS Tasks
ECS Cluster
ECS Tasks
ECS Cluster
ECS Cluster
EC2 Instance
ECS Cluster
ECS Cluster
ECS Cluster
ECS Tasks
User
EC2 Instance
ECS Cluster
(...)
load_balancer {
elb_name = "${aws_elb.rails_frontend.id}"
container_name = "rails-frontend"
container_port = 3000
}
}
(...)
load_balancer {
elb_name = "${aws_elb.sinatra_backend.id}"
container_name = "sinatra-backend"
container_port = 4567
}
}
ECS Tasks
EC2 Instance
ECS Cluster
ECS Tasks
ECS Scheduler
ECS Task Definition ECS Service Definition
EC2 Instance
ECS Cluster
-/+ aws_ecs_task_definition.sinatra_backend
arn: "arn...sinatra-backend:3" => "<computed>"
container_definitions: "bb5352f" => "2ff6ae" (forces new resource)
revision: "3" => "<computed>”
1. UI is so-so
2. Minimal monitoring built-in
3. ALB is broken
Outline
1. Microservices
2. Docker
3. Terraform
4. ECS
5. Recap
Benefits of infrastructure-as-code:
1. Reuse
2. Automation
3. Version control
4. Code review
5. Testing
6. Documentation
Slides and code from this talk:
ybrikman.com/speaking
For more
info, see
Hello,
Startup
hello-startup.net
And
Terraform:
Up & Running
terraformupandrunning.com
For DevOps help, see
Gruntwork
gruntwork.io
Questions?