SlideShare a Scribd company logo
1 of 34
Download to read offline
Nadav Soferman
Cloudinary’s Co-Founder & CPO
Building and Scaling a B2D Service
The Cloudinary Story
Initial Vision Late 2011
Eliminate all image related R&D work
(Upload, storage, administration, manipulation, optimization, delivery)
Cloud based API for image upload
URL based API for on-the-fly image manipulation
http://res.cloudinary.com/demo/image/upload/w_180,h_140,c_thumb,g_face/bike.jpg
Initial Vision
Help Developers If it makes money,
that’s nice too :-)
Bigger Dream
10+
Developers
10M+
Daily New Images
1PB+
Monthly Bandwidth
1000+
CPUs
30+
Employees
2+
Offices
50K+
Users (Developers)
2000+
Paying Customers
$10,000,000
Initial Funding Required
Become the leading image back-end of the web
Nadav Soferman
Cloudinary’s Co-Founder & CPO
Building and Scaling a B2D Service
The Cloudinary Story
The Bootstrapped Way$0 Funding
First Architecture
A Single Virtual Server
AWS (Amazon Web Services)
EC2 (Elastic Compute Cloud)
Early 2012
Don’t re-implement the wheel
Use existing solutions. Use open source solutions.
Use cloud services. Use AWS.
Keep it simple. 80/20 Rule. Always. Unless it is fun…
First Architecture
A Single Virtual ServerRuby on Rails
Application
Business Logic, Image processing
MySQL
Database
nginx + Passenger
Web server
AWS S3
Storage
AWS CloudFront
CDN
Early 2012
http://res.cloudinary.com/demo/image/upload/w_133,h_133,c_thumb,g_face/bike.jpg
The Importance Of Caching
Multiple cache layers to protect your application server
Generated images
are stored in S3
Fast nginx with
S3 access
CDN as the
main cache layer
On-the-fly image processing Tons of user requests
Image manipulation performance relevant only to first user
Don’t optimize performance yet
(and no need for GPU acceleration…)
Getting Initial Traction
Nice Initial
Vision
Implemented
A Cool Service
Cloud-based API
Publicly Available ?
What now?
What Do Developers Want?
We started with a Ruby GEM
for Ruby on Rails Web developers
Developers love
minimal code changes
Developers look for
simple SDKs
Public API
is not enough
Developers Want One-Liners
http://res.cloudinary.com/demo/image/upload/w_150,h_150,c_fill/bike.jpg
Instead of manually building URLs:
<%= image_tag("bike.jpg", :width => 150, :height => 150) %>
Rails developers are used to image_tag:
<%= cl_image_tag("bike.jpg", :width => 150, :height => 150,
:crop => :fill) %>
Providing a similar view helper method:
<%= cl_image_tag("bike.jpg", :width => 150, :height => 150,
:crop => :thumb, :gravity => :face) %>
Additional manipulation options, everything is done in the cloud:
Developers Love One-Liners
Local/S3 storage.
Local RMagick/MiniMagick.
Regular URLs.
class PictureUploader < CarrierWave::Uploader::Base
process convert: 'jpg'
version :standard do
process resize_to_fill: [100, 150, :north]
end
version :thumbnail do
process resize_to_fit: [80, 80]
end
end
class Post < ActiveRecord::Base
...
mount_uploader :picture, PictureUploader
...
end
Cloud image storage.
Cloud image processing.
CDN URLs.
include Cloudinary::CarrierWave Original code, without Cloudinary
With Cloudinary, adding one line
Developer Religions
Need to support all frameworks. Tight integrations
And specific sub-frameworks…
But jQuery-free Javascript for Angular people…
Developer Religions
Each religion framework has different conventions and rules
Ruby GEM
330,000 Downloads
500+ Paying customers
But still…
cloudinary.uploader.upload("my_picture.jpg",
function(result) { … },
{ crop: "limit", width: 2000 }
);
Wrong…
cloudinary.uploader.upload("my_picture.jpg",
{ crop: "limit", width: 2000 },
function(error, result) { … },
);
Great…
Framework Trends
Percentage of customers by framework (last 2 years):
And the new rising star is…
Documentation and Blog
API Documentation,
Framework specific guides
Technical posts, Tutorials,
Cookbook recipes
SDKs must be accompanied with detailed documentation
Great SEO impact. Most of Cloudinary’s customers
arrive due to technical content on the website
Documentation and Blog
Hard work, but very appreciated Or not…
Having great technical support does the rest of the work
From developers
to developers
1,000 support tickets
last month
Multiple EC2 instances (Auto Scaling group)
Separated UI and API clusters
Updated Architecture
Ruby on Rails - Application
Business Logic, Image processing,
Background processing
nginx + Passenger
Web server
AWS S3
Storage
Akamai
CDN
Early 2013
AWS SQS
Queuing service
AWS RDS (Multi-AZ)
Hosted MySQL Database
AWS ELB
Load Balancer
API
Requests
Switched to Akamai CDN
Charge per request x 15KB Average image size = Requests cost > Bandwidth cost
Customers demanded Akamai Wider global presence
Better cache invalidation
CloudFront was great, but:
And… surprisingly, has better pricing
Don’t waste money on
too many extra servers…
The Auto Scaling Challenge
Handle bursts of image requests
Scale up as quickly as possible
Define correct scale sensors (CPU or IO)
Keep enough extra servers upHandle single customer’s website bursts
Handle growth of customers & traffic
Better Auto Scaling
AWS Auto Scaling Group
Always have enough extra servers
Multiple availability zones
Optimized AMI with minimal setup on load
High average CPU utilization High number of active Passengers
Reserve
instances
to cut costs
Handling Single Customer Bursts
A single customer should not break the system for others
Specifically in bursts while launching new sites
Limit the number of Rails
processes (passenger) per customer
Until the system
auto scales up…
And cache errors in S3 for faster delivery by nginx
System Monitoring
Our service is in the heart of our customer’s production services
System must always work perfectly
Monitoring is critical
Deliver Cloudinary-based image
ads to viewers of the largest most
popular news sites worldwide
For example:
System Monitoring
Leveraging 3rd-party and in-house monitoring services
AWS
CloudWatch
Log Analysis, Applicative Monitoring and more
And… to make sure
we wake up at night:
Automatic phone
calls to the team
Battle Tested
So many possible cases. Endless potential errors
Many image formats Many color profiles Many frameworks
Many devices Many versions Many resolutionsMany operating systems
Analyzing all errors Thousands of automatic tests
EC2 strong SSD instances (Auto Scaling group)
Separated UI and API clusters
Ruby on Rails - Application
Business Logic, Image processing,
Background processing
nginx + Passenger
Web server
RedisScala Daemon
Advanced Architecture
AWS S3
Storage Akamai
CDN
Late 2014
AWS SQS
Queuing service
AWS ELB
Load Balancer
MySQL Clusters
Sharded Databases
MySQL Clusters
Sharded Databases
MySQL Clusters
Sharded Databases
MySQL Clusters
Sharded Databases
MySQL Clusters
Sharded Databases
Cassandra
NoSQL DB Cluster
MySQL Clusters
Sharded Databases
MySQL Clusters
Sharded Databases
ElasticSearch
Indexing Cluster
3rd Party Add-ons
MySQL
Clusters
MySQL
Clusters
LogStash Cluster
Log monitoring
API
Requests
AWS - Cost Effective
Not expensive as its reputation
Reserved instances
Powerful services
Don’t build by yourself…
Very flexible
Quick-start boost
Performance Analysis
Time to improve processing performance and reduce CPU costs
The main
suspects…
Multiple Thumbnails Image Rotation
Displayed interactive results using D3 charts
Stored data in Cassandra database
Tracked sampled transformation CPU usage
Face Detection
Performance Analysis Result
The culprit: Ruby execution of external image processing commands
def run_external(command, options={})
Open3.popen3(command) do
|stdin, stdout, stderr, wait_thr|
stdin.binmode
stdout.binmode
stderr.binmode
stdin.write(options[:input]) if options[:input]
stdin.close
begin
Timeout::timeout(options[:timeout]) do
return nil if wait_thr.value != 0
return [stdout.read, stderr.read]
end
rescue Timeout::Error
Process::kill("TERM", wait_thr.pid)
return nil
end
end
end
Original code - Very slow
def run_external(command, options={})
child = POSIX::Spawn::Child.new(command,
options.slice(:timeout, :input))
if child.success?
return [child.out, child.err]
else
Rails.logger.warn(
"Failed: #{child.out} #{child.err}")
nil
end
rescue POSIX::Spawn::TimeoutExceeded
Rails.logger.warn("#{command} - Timeout exceeded")
nil
end
Updated code - Much faster
Performance Boost
30%
Drop in
overall system
CPU utilization
25%
Drop in web transaction’s
average response time
The Bootstrapped Way
Worked well for us :-)
Small team of great people
Gradual architecture
Great service. Great support
Grassroots marketing. Content oriented
Gradual features. Customer first
And it’s just the beginning….
Today’s Numbers. What’s Next?
Developers signed-up Paying customers from 65 countries
Daily new images Daily image delivered
* Not including CDN layer of customers…
From startups to Fortune 500 companies
CPU cores
55,000 2,000
20 Million 1.5 Billion 1,000
Architecture keeps evolvingScale challenges getting complex
Being customer focused - New features every week…
One more thing…
Debated since day one. Glad we didn’t implement it too early :-)
The market is ready now. Customers requested
Same capabilities of images, now also for video
http://res.cloudinary.com/demo/video/upload/w_200,h_200,c_fill,g_north/dog.mp4
Longer processing times. Heavier processing.
Significant architecture changes. New clusters…
Questions?
Thank you!
nadav.soferman@cloudinary.com
www.cloudinary.com@cloudinary facebook.com/Cloudinary

More Related Content

What's hot

AWS 101 and the benefits of Migrating to the Cloud
AWS 101 and the benefits of Migrating to the CloudAWS 101 and the benefits of Migrating to the Cloud
AWS 101 and the benefits of Migrating to the CloudCloudHesive
 
High Performance Computing on AWS
High Performance Computing on AWSHigh Performance Computing on AWS
High Performance Computing on AWSAmazon Web Services
 
Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018
Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018
Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018Amazon Web Services
 
High Performance Computing on AWS: Accelerating Innovation with virtually unl...
High Performance Computing on AWS: Accelerating Innovation with virtually unl...High Performance Computing on AWS: Accelerating Innovation with virtually unl...
High Performance Computing on AWS: Accelerating Innovation with virtually unl...Amazon Web Services
 
Simple Cloud with Amazon Lightsail
Simple Cloud with Amazon LightsailSimple Cloud with Amazon Lightsail
Simple Cloud with Amazon LightsailAmazon Web Services
 
Intro to AWS Batch & How AQR Capital leverages AWS to Identify New Investment...
Intro to AWS Batch & How AQR Capital leverages AWS to Identify New Investment...Intro to AWS Batch & How AQR Capital leverages AWS to Identify New Investment...
Intro to AWS Batch & How AQR Capital leverages AWS to Identify New Investment...Amazon Web Services
 
How to Move to Amazon WorkSpaces and Replace Your Legacy VDI (BAP305) - AWS r...
How to Move to Amazon WorkSpaces and Replace Your Legacy VDI (BAP305) - AWS r...How to Move to Amazon WorkSpaces and Replace Your Legacy VDI (BAP305) - AWS r...
How to Move to Amazon WorkSpaces and Replace Your Legacy VDI (BAP305) - AWS r...Amazon Web Services
 
Deep Dive on Amazon EC2 Accelerated Computing
Deep Dive on Amazon EC2 Accelerated ComputingDeep Dive on Amazon EC2 Accelerated Computing
Deep Dive on Amazon EC2 Accelerated ComputingAmazon Web Services
 
AWS re:Invent 2016: Powering the Next Generation of Virtual Reality with Veri...
AWS re:Invent 2016: Powering the Next Generation of Virtual Reality with Veri...AWS re:Invent 2016: Powering the Next Generation of Virtual Reality with Veri...
AWS re:Invent 2016: Powering the Next Generation of Virtual Reality with Veri...Amazon Web Services
 
Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot Instances...
Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot Instances...Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot Instances...
Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot Instances...Amazon Web Services
 
Accelerating Application Development with Amazon Aurora (DAT312-R2) - AWS re:...
Accelerating Application Development with Amazon Aurora (DAT312-R2) - AWS re:...Accelerating Application Development with Amazon Aurora (DAT312-R2) - AWS re:...
Accelerating Application Development with Amazon Aurora (DAT312-R2) - AWS re:...Amazon Web Services
 
Dell EMC Data Protection Enables Simple, Secure Backup & Restore on AWS (STG3...
Dell EMC Data Protection Enables Simple, Secure Backup & Restore on AWS (STG3...Dell EMC Data Protection Enables Simple, Secure Backup & Restore on AWS (STG3...
Dell EMC Data Protection Enables Simple, Secure Backup & Restore on AWS (STG3...Amazon Web Services
 
以 Amazon EC2 Spot 執行個體有效控制專案成本 (Level: 200)
以 Amazon EC2 Spot 執行個體有效控制專案成本 (Level: 200)以 Amazon EC2 Spot 執行個體有效控制專案成本 (Level: 200)
以 Amazon EC2 Spot 執行個體有效控制專案成本 (Level: 200)Amazon Web Services
 
Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018
Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018
Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018Amazon Web Services
 
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018Amazon Web Services
 

What's hot (20)

AWS 101 and the benefits of Migrating to the Cloud
AWS 101 and the benefits of Migrating to the CloudAWS 101 and the benefits of Migrating to the Cloud
AWS 101 and the benefits of Migrating to the Cloud
 
High Performance Computing on AWS
High Performance Computing on AWSHigh Performance Computing on AWS
High Performance Computing on AWS
 
AWS Business Essentials
AWS Business EssentialsAWS Business Essentials
AWS Business Essentials
 
Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018
Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018
Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018
 
High Performance Computing on AWS: Accelerating Innovation with virtually unl...
High Performance Computing on AWS: Accelerating Innovation with virtually unl...High Performance Computing on AWS: Accelerating Innovation with virtually unl...
High Performance Computing on AWS: Accelerating Innovation with virtually unl...
 
Simple Cloud with Amazon Lightsail
Simple Cloud with Amazon LightsailSimple Cloud with Amazon Lightsail
Simple Cloud with Amazon Lightsail
 
Intro to AWS Batch & How AQR Capital leverages AWS to Identify New Investment...
Intro to AWS Batch & How AQR Capital leverages AWS to Identify New Investment...Intro to AWS Batch & How AQR Capital leverages AWS to Identify New Investment...
Intro to AWS Batch & How AQR Capital leverages AWS to Identify New Investment...
 
How to Move to Amazon WorkSpaces and Replace Your Legacy VDI (BAP305) - AWS r...
How to Move to Amazon WorkSpaces and Replace Your Legacy VDI (BAP305) - AWS r...How to Move to Amazon WorkSpaces and Replace Your Legacy VDI (BAP305) - AWS r...
How to Move to Amazon WorkSpaces and Replace Your Legacy VDI (BAP305) - AWS r...
 
Builders' Day - What's New on EC2
Builders' Day - What's New on EC2Builders' Day - What's New on EC2
Builders' Day - What's New on EC2
 
Deep Dive on Amazon EC2 Accelerated Computing
Deep Dive on Amazon EC2 Accelerated ComputingDeep Dive on Amazon EC2 Accelerated Computing
Deep Dive on Amazon EC2 Accelerated Computing
 
AWS 101
AWS 101AWS 101
AWS 101
 
AWS re:Invent 2016: Powering the Next Generation of Virtual Reality with Veri...
AWS re:Invent 2016: Powering the Next Generation of Virtual Reality with Veri...AWS re:Invent 2016: Powering the Next Generation of Virtual Reality with Veri...
AWS re:Invent 2016: Powering the Next Generation of Virtual Reality with Veri...
 
Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot Instances...
Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot Instances...Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot Instances...
Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot Instances...
 
Accelerating Application Development with Amazon Aurora (DAT312-R2) - AWS re:...
Accelerating Application Development with Amazon Aurora (DAT312-R2) - AWS re:...Accelerating Application Development with Amazon Aurora (DAT312-R2) - AWS re:...
Accelerating Application Development with Amazon Aurora (DAT312-R2) - AWS re:...
 
Virtual AWSome Day Training
Virtual AWSome Day TrainingVirtual AWSome Day Training
Virtual AWSome Day Training
 
Dell EMC Data Protection Enables Simple, Secure Backup & Restore on AWS (STG3...
Dell EMC Data Protection Enables Simple, Secure Backup & Restore on AWS (STG3...Dell EMC Data Protection Enables Simple, Secure Backup & Restore on AWS (STG3...
Dell EMC Data Protection Enables Simple, Secure Backup & Restore on AWS (STG3...
 
AWS for Wicked Rugby
AWS for Wicked RugbyAWS for Wicked Rugby
AWS for Wicked Rugby
 
以 Amazon EC2 Spot 執行個體有效控制專案成本 (Level: 200)
以 Amazon EC2 Spot 執行個體有效控制專案成本 (Level: 200)以 Amazon EC2 Spot 執行個體有效控制專案成本 (Level: 200)
以 Amazon EC2 Spot 執行個體有效控制專案成本 (Level: 200)
 
Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018
Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018
Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018
 
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018
 

Similar to Building and scaling a B2D service, the bootstrap way

The Future is Now: Leveraging the Cloud with Ruby
The Future is Now: Leveraging the Cloud with RubyThe Future is Now: Leveraging the Cloud with Ruby
The Future is Now: Leveraging the Cloud with RubyRobert Dempsey
 
AWS Webcast - What is Cloud Computing?
AWS Webcast - What is Cloud Computing?AWS Webcast - What is Cloud Computing?
AWS Webcast - What is Cloud Computing?Amazon Web Services
 
Create Agile, Automated and Predictable IT Infrastructure in the Cloud
Create Agile, Automated and Predictable IT Infrastructure in the CloudCreate Agile, Automated and Predictable IT Infrastructure in the Cloud
Create Agile, Automated and Predictable IT Infrastructure in the CloudRightScale
 
Rails in the Cloud
Rails in the CloudRails in the Cloud
Rails in the Cloudiwarshak
 
Exploring Cloud Computing with Amazon Web Services (AWS)
Exploring Cloud Computing with Amazon Web Services (AWS)Exploring Cloud Computing with Amazon Web Services (AWS)
Exploring Cloud Computing with Amazon Web Services (AWS)Kalema Edgar
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Emerson Eduardo Rodrigues Von Staffen
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...Amazon Web Services
 
Voxxed Athens 2018 - Serverless by Design
Voxxed Athens 2018 - Serverless by DesignVoxxed Athens 2018 - Serverless by Design
Voxxed Athens 2018 - Serverless by DesignVoxxed Athens
 
Cloud computing-Practical Example
Cloud computing-Practical ExampleCloud computing-Practical Example
Cloud computing-Practical ExampleTasawar Gulzar
 
Intro To Serverless Application Architecture: Collision 2018
Intro To Serverless Application Architecture: Collision 2018Intro To Serverless Application Architecture: Collision 2018
Intro To Serverless Application Architecture: Collision 2018Amazon Web Services
 
Design for Scale - Building Real Time, High Performing Marketing Technology p...
Design for Scale - Building Real Time, High Performing Marketing Technology p...Design for Scale - Building Real Time, High Performing Marketing Technology p...
Design for Scale - Building Real Time, High Performing Marketing Technology p...Amazon Web Services
 
ServerTemplate Deep Dive
ServerTemplate Deep DiveServerTemplate Deep Dive
ServerTemplate Deep DiveRightScale
 
Creating scalable solutions with aws
Creating scalable solutions with awsCreating scalable solutions with aws
Creating scalable solutions with awsondrejbalas
 
Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series
Announcing Lambda @ the Edge - December 2016 Monthly Webinar SeriesAnnouncing Lambda @ the Edge - December 2016 Monthly Webinar Series
Announcing Lambda @ the Edge - December 2016 Monthly Webinar SeriesAmazon Web Services
 
AWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWSAWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWSAmazon Web Services
 
AWS Summit Stockholm 2014 – B4 – Business intelligence on AWS
AWS Summit Stockholm 2014 – B4 – Business intelligence on AWSAWS Summit Stockholm 2014 – B4 – Business intelligence on AWS
AWS Summit Stockholm 2014 – B4 – Business intelligence on AWSAmazon Web Services
 
Best-Practices-for-Running-Windows-Workloads-on-AWS
Best-Practices-for-Running-Windows-Workloads-on-AWSBest-Practices-for-Running-Windows-Workloads-on-AWS
Best-Practices-for-Running-Windows-Workloads-on-AWSAmazon Web Services
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Editionecobold
 

Similar to Building and scaling a B2D service, the bootstrap way (20)

The Future is Now: Leveraging the Cloud with Ruby
The Future is Now: Leveraging the Cloud with RubyThe Future is Now: Leveraging the Cloud with Ruby
The Future is Now: Leveraging the Cloud with Ruby
 
AWS Webcast - What is Cloud Computing?
AWS Webcast - What is Cloud Computing?AWS Webcast - What is Cloud Computing?
AWS Webcast - What is Cloud Computing?
 
Create Agile, Automated and Predictable IT Infrastructure in the Cloud
Create Agile, Automated and Predictable IT Infrastructure in the CloudCreate Agile, Automated and Predictable IT Infrastructure in the Cloud
Create Agile, Automated and Predictable IT Infrastructure in the Cloud
 
Rails in the Cloud
Rails in the CloudRails in the Cloud
Rails in the Cloud
 
Exploring Cloud Computing with Amazon Web Services (AWS)
Exploring Cloud Computing with Amazon Web Services (AWS)Exploring Cloud Computing with Amazon Web Services (AWS)
Exploring Cloud Computing with Amazon Web Services (AWS)
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
 
IP Expo - What is AWS?
IP Expo - What is AWS?IP Expo - What is AWS?
IP Expo - What is AWS?
 
Voxxed Athens 2018 - Serverless by Design
Voxxed Athens 2018 - Serverless by DesignVoxxed Athens 2018 - Serverless by Design
Voxxed Athens 2018 - Serverless by Design
 
Cloud computing-Practical Example
Cloud computing-Practical ExampleCloud computing-Practical Example
Cloud computing-Practical Example
 
Intro To Serverless Application Architecture: Collision 2018
Intro To Serverless Application Architecture: Collision 2018Intro To Serverless Application Architecture: Collision 2018
Intro To Serverless Application Architecture: Collision 2018
 
Design for Scale - Building Real Time, High Performing Marketing Technology p...
Design for Scale - Building Real Time, High Performing Marketing Technology p...Design for Scale - Building Real Time, High Performing Marketing Technology p...
Design for Scale - Building Real Time, High Performing Marketing Technology p...
 
ServerTemplate Deep Dive
ServerTemplate Deep DiveServerTemplate Deep Dive
ServerTemplate Deep Dive
 
Creating scalable solutions with aws
Creating scalable solutions with awsCreating scalable solutions with aws
Creating scalable solutions with aws
 
Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series
Announcing Lambda @ the Edge - December 2016 Monthly Webinar SeriesAnnouncing Lambda @ the Edge - December 2016 Monthly Webinar Series
Announcing Lambda @ the Edge - December 2016 Monthly Webinar Series
 
AWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWSAWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWS
 
AWS Summit Stockholm 2014 – B4 – Business intelligence on AWS
AWS Summit Stockholm 2014 – B4 – Business intelligence on AWSAWS Summit Stockholm 2014 – B4 – Business intelligence on AWS
AWS Summit Stockholm 2014 – B4 – Business intelligence on AWS
 
Best-Practices-for-Running-Windows-Workloads-on-AWS
Best-Practices-for-Running-Windows-Workloads-on-AWSBest-Practices-for-Running-Windows-Workloads-on-AWS
Best-Practices-for-Running-Windows-Workloads-on-AWS
 
Amazon ECS
Amazon ECSAmazon ECS
Amazon ECS
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Edition
 

Recently uploaded

James Joyce, Dubliners and Ulysses.ppt !
James Joyce, Dubliners and Ulysses.ppt !James Joyce, Dubliners and Ulysses.ppt !
James Joyce, Dubliners and Ulysses.ppt !risocarla2016
 
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...漢銘 謝
 
call girls in delhi malviya nagar @9811711561@
call girls in delhi malviya nagar @9811711561@call girls in delhi malviya nagar @9811711561@
call girls in delhi malviya nagar @9811711561@vikas rana
 
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxGenesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxFamilyWorshipCenterD
 
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC  - NANOTECHNOLOGYPHYSICS PROJECT BY MSC  - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC - NANOTECHNOLOGYpruthirajnayak525
 
The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringSebastiano Panichella
 
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Krijn Poppe
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸mathanramanathan2005
 
miladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptxmiladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptxCarrieButtitta
 
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSebastiano Panichella
 
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.KathleenAnnCordero2
 
Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Escort Service
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxmavinoikein
 
Event 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxEvent 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxaryanv1753
 
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.comSaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.comsaastr
 
Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxJohnree4
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSebastiano Panichella
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationNathan Young
 
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...marjmae69
 

Recently uploaded (20)

James Joyce, Dubliners and Ulysses.ppt !
James Joyce, Dubliners and Ulysses.ppt !James Joyce, Dubliners and Ulysses.ppt !
James Joyce, Dubliners and Ulysses.ppt !
 
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
 
call girls in delhi malviya nagar @9811711561@
call girls in delhi malviya nagar @9811711561@call girls in delhi malviya nagar @9811711561@
call girls in delhi malviya nagar @9811711561@
 
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxGenesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
 
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC  - NANOTECHNOLOGYPHYSICS PROJECT BY MSC  - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
 
The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software Engineering
 
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸
 
miladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptxmiladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptx
 
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation Track
 
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
 
Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptx
 
Event 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxEvent 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptx
 
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.comSaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
 
Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptx
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism Presentation
 
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
 

Building and scaling a B2D service, the bootstrap way

  • 1. Nadav Soferman Cloudinary’s Co-Founder & CPO Building and Scaling a B2D Service The Cloudinary Story
  • 2. Initial Vision Late 2011 Eliminate all image related R&D work (Upload, storage, administration, manipulation, optimization, delivery) Cloud based API for image upload URL based API for on-the-fly image manipulation http://res.cloudinary.com/demo/image/upload/w_180,h_140,c_thumb,g_face/bike.jpg
  • 3. Initial Vision Help Developers If it makes money, that’s nice too :-)
  • 4. Bigger Dream 10+ Developers 10M+ Daily New Images 1PB+ Monthly Bandwidth 1000+ CPUs 30+ Employees 2+ Offices 50K+ Users (Developers) 2000+ Paying Customers $10,000,000 Initial Funding Required Become the leading image back-end of the web
  • 5. Nadav Soferman Cloudinary’s Co-Founder & CPO Building and Scaling a B2D Service The Cloudinary Story The Bootstrapped Way$0 Funding
  • 6. First Architecture A Single Virtual Server AWS (Amazon Web Services) EC2 (Elastic Compute Cloud) Early 2012 Don’t re-implement the wheel Use existing solutions. Use open source solutions. Use cloud services. Use AWS. Keep it simple. 80/20 Rule. Always. Unless it is fun…
  • 7. First Architecture A Single Virtual ServerRuby on Rails Application Business Logic, Image processing MySQL Database nginx + Passenger Web server AWS S3 Storage AWS CloudFront CDN Early 2012 http://res.cloudinary.com/demo/image/upload/w_133,h_133,c_thumb,g_face/bike.jpg
  • 8. The Importance Of Caching Multiple cache layers to protect your application server Generated images are stored in S3 Fast nginx with S3 access CDN as the main cache layer On-the-fly image processing Tons of user requests Image manipulation performance relevant only to first user Don’t optimize performance yet (and no need for GPU acceleration…)
  • 9. Getting Initial Traction Nice Initial Vision Implemented A Cool Service Cloud-based API Publicly Available ? What now?
  • 10. What Do Developers Want? We started with a Ruby GEM for Ruby on Rails Web developers Developers love minimal code changes Developers look for simple SDKs Public API is not enough
  • 11. Developers Want One-Liners http://res.cloudinary.com/demo/image/upload/w_150,h_150,c_fill/bike.jpg Instead of manually building URLs: <%= image_tag("bike.jpg", :width => 150, :height => 150) %> Rails developers are used to image_tag: <%= cl_image_tag("bike.jpg", :width => 150, :height => 150, :crop => :fill) %> Providing a similar view helper method: <%= cl_image_tag("bike.jpg", :width => 150, :height => 150, :crop => :thumb, :gravity => :face) %> Additional manipulation options, everything is done in the cloud:
  • 12. Developers Love One-Liners Local/S3 storage. Local RMagick/MiniMagick. Regular URLs. class PictureUploader < CarrierWave::Uploader::Base process convert: 'jpg' version :standard do process resize_to_fill: [100, 150, :north] end version :thumbnail do process resize_to_fit: [80, 80] end end class Post < ActiveRecord::Base ... mount_uploader :picture, PictureUploader ... end Cloud image storage. Cloud image processing. CDN URLs. include Cloudinary::CarrierWave Original code, without Cloudinary With Cloudinary, adding one line
  • 13. Developer Religions Need to support all frameworks. Tight integrations And specific sub-frameworks… But jQuery-free Javascript for Angular people…
  • 14. Developer Religions Each religion framework has different conventions and rules Ruby GEM 330,000 Downloads 500+ Paying customers But still… cloudinary.uploader.upload("my_picture.jpg", function(result) { … }, { crop: "limit", width: 2000 } ); Wrong… cloudinary.uploader.upload("my_picture.jpg", { crop: "limit", width: 2000 }, function(error, result) { … }, ); Great…
  • 15. Framework Trends Percentage of customers by framework (last 2 years): And the new rising star is…
  • 16. Documentation and Blog API Documentation, Framework specific guides Technical posts, Tutorials, Cookbook recipes SDKs must be accompanied with detailed documentation Great SEO impact. Most of Cloudinary’s customers arrive due to technical content on the website
  • 17. Documentation and Blog Hard work, but very appreciated Or not… Having great technical support does the rest of the work From developers to developers 1,000 support tickets last month
  • 18. Multiple EC2 instances (Auto Scaling group) Separated UI and API clusters Updated Architecture Ruby on Rails - Application Business Logic, Image processing, Background processing nginx + Passenger Web server AWS S3 Storage Akamai CDN Early 2013 AWS SQS Queuing service AWS RDS (Multi-AZ) Hosted MySQL Database AWS ELB Load Balancer API Requests
  • 19. Switched to Akamai CDN Charge per request x 15KB Average image size = Requests cost > Bandwidth cost Customers demanded Akamai Wider global presence Better cache invalidation CloudFront was great, but: And… surprisingly, has better pricing
  • 20. Don’t waste money on too many extra servers… The Auto Scaling Challenge Handle bursts of image requests Scale up as quickly as possible Define correct scale sensors (CPU or IO) Keep enough extra servers upHandle single customer’s website bursts Handle growth of customers & traffic
  • 21. Better Auto Scaling AWS Auto Scaling Group Always have enough extra servers Multiple availability zones Optimized AMI with minimal setup on load High average CPU utilization High number of active Passengers Reserve instances to cut costs
  • 22. Handling Single Customer Bursts A single customer should not break the system for others Specifically in bursts while launching new sites Limit the number of Rails processes (passenger) per customer Until the system auto scales up… And cache errors in S3 for faster delivery by nginx
  • 23. System Monitoring Our service is in the heart of our customer’s production services System must always work perfectly Monitoring is critical Deliver Cloudinary-based image ads to viewers of the largest most popular news sites worldwide For example:
  • 24. System Monitoring Leveraging 3rd-party and in-house monitoring services AWS CloudWatch Log Analysis, Applicative Monitoring and more And… to make sure we wake up at night: Automatic phone calls to the team
  • 25. Battle Tested So many possible cases. Endless potential errors Many image formats Many color profiles Many frameworks Many devices Many versions Many resolutionsMany operating systems Analyzing all errors Thousands of automatic tests
  • 26. EC2 strong SSD instances (Auto Scaling group) Separated UI and API clusters Ruby on Rails - Application Business Logic, Image processing, Background processing nginx + Passenger Web server RedisScala Daemon Advanced Architecture AWS S3 Storage Akamai CDN Late 2014 AWS SQS Queuing service AWS ELB Load Balancer MySQL Clusters Sharded Databases MySQL Clusters Sharded Databases MySQL Clusters Sharded Databases MySQL Clusters Sharded Databases MySQL Clusters Sharded Databases Cassandra NoSQL DB Cluster MySQL Clusters Sharded Databases MySQL Clusters Sharded Databases ElasticSearch Indexing Cluster 3rd Party Add-ons MySQL Clusters MySQL Clusters LogStash Cluster Log monitoring API Requests
  • 27. AWS - Cost Effective Not expensive as its reputation Reserved instances Powerful services Don’t build by yourself… Very flexible Quick-start boost
  • 28. Performance Analysis Time to improve processing performance and reduce CPU costs The main suspects… Multiple Thumbnails Image Rotation Displayed interactive results using D3 charts Stored data in Cassandra database Tracked sampled transformation CPU usage Face Detection
  • 29. Performance Analysis Result The culprit: Ruby execution of external image processing commands def run_external(command, options={}) Open3.popen3(command) do |stdin, stdout, stderr, wait_thr| stdin.binmode stdout.binmode stderr.binmode stdin.write(options[:input]) if options[:input] stdin.close begin Timeout::timeout(options[:timeout]) do return nil if wait_thr.value != 0 return [stdout.read, stderr.read] end rescue Timeout::Error Process::kill("TERM", wait_thr.pid) return nil end end end Original code - Very slow def run_external(command, options={}) child = POSIX::Spawn::Child.new(command, options.slice(:timeout, :input)) if child.success? return [child.out, child.err] else Rails.logger.warn( "Failed: #{child.out} #{child.err}") nil end rescue POSIX::Spawn::TimeoutExceeded Rails.logger.warn("#{command} - Timeout exceeded") nil end Updated code - Much faster
  • 30. Performance Boost 30% Drop in overall system CPU utilization 25% Drop in web transaction’s average response time
  • 31. The Bootstrapped Way Worked well for us :-) Small team of great people Gradual architecture Great service. Great support Grassroots marketing. Content oriented Gradual features. Customer first
  • 32. And it’s just the beginning…. Today’s Numbers. What’s Next? Developers signed-up Paying customers from 65 countries Daily new images Daily image delivered * Not including CDN layer of customers… From startups to Fortune 500 companies CPU cores 55,000 2,000 20 Million 1.5 Billion 1,000 Architecture keeps evolvingScale challenges getting complex Being customer focused - New features every week…
  • 33. One more thing… Debated since day one. Glad we didn’t implement it too early :-) The market is ready now. Customers requested Same capabilities of images, now also for video http://res.cloudinary.com/demo/video/upload/w_200,h_200,c_fill,g_north/dog.mp4 Longer processing times. Heavier processing. Significant architecture changes. New clusters…