This document provides an overview and agenda for a presentation on architecting for the cloud using the Netflix approach. Some key points:
- Netflix has over 40 million members streaming over 1 billion hours per month of content across over 40 countries.
- Netflix runs on AWS and handles billions of requests per day across thousands of instances globally.
- The presentation will discuss how to build your own platform as a service (PaaS) based on Netflix's open source libraries, including platform services, libraries, and tools.
- The Netflix approach focuses on microservices, automation, and resilience to support rapid iteration on cloud infrastructure.
Unleash Your Potential - Namagunga Girls Coding Club
Architecting for the Cloud using NetflixOSS - Codemash Workshop
1. Architecting for the Cloud
- The Netflix Way!
Codemash PreCompiler Workshop
- Jan 8th 2014
Sudhir Tonse
Manager, Cloud Platform Infrastructure
@stonse
2. NETFLIX
Netflix is the world’s leading Internet television
network with more than 40 million members in >40
countries enjoying more than one billion hours of TV
shows and movies per month, including original
series.
3. NETFLIX SCALE
• 100s of Mid-tier services and applications
• Billions of Requests per day
• ~70 Billion Events per day
• 10,000s of Ec2 Instances in use in multiple AWS Regions/
Zones
• Cassandra NoSQL database in a Global Ring spanning
regions: Terabytes of data
• At peak consumes ~1/3 of US Internet Bandwidth
4. I am PaaS (and so can You!)
Your Cloud PaaS
@stonse
6. Agenda
•
PaaS? What is it good for?
•
NetflixOSS -> Build your own PaaS the Netflix Way!
• What you need to build, deploy and operate a Cloud Native set of applications
• Cloud Native Architecture
• Platform Services -> Application Services on top of IaaS
• Platform Libraries -> Application Framework Libraries
• Platform Tools/Operational Utilities -> Helps deploy and manage your
Cloud Apps
•
@stonse
Build your own Web Service using NetflixOSS libraries
7. PaaS? What is it?
Libraries, Tools and Frameworks that enable
one to Build, Deploy and Manage Software
Services on Ephemeral, On Demand Virtual
Machines (IaaS)
@stonse
18. Think …
Cloud Native Architecture
@stonse
More at http://www.siia.net/presentations/software/
AATC2013/OpenSourceAtNetflix.pdf
- Adrian Cockroft (@adrianco)
25. • RPS
• Load Average
Slow Growth
Predictable Bursts
Compute
• …
Time
Time
Compute
• Use CloudWatch
Time
Periodic Jobs
Compute
Scale UP & Down based on
Demand
Compute
•
Compute
ON DEMAND AUTO SCALING!
Time
Unpredictable Bursts
Time
Steady State
40. STEP 1
Choice A: Bare bones Web Service Template
$git clone https://github.com/Netflix/karyon.git
$cd karyon
$./gradlew clean build
$./gradlew :karyon-examples:hello-netflixoss:jettyRun
Choice B: Full blown Recipe (RSS Reader
Recipe)
$git clone https://github.com/Netflix/recipes-rss.git
$cd recipes-rss
$./gradlew clean build
@stonse
41. STEP 2
•
Customize your App using .war of previous step as a template
• TIPS (optional)
• Use Ribbon for RPC calls
• Use Hystrix/RxJava for wrapping concurrent calls/RPC calls (Latency/Fault
Tolerance)
@stonse
51. RIBBON (RPC) CALL
try {
RestClient client = (RestClient)
ClientFactory.getNamedClient("FlixmashClient");
HttpRequest request = HttpRequest.newBuilder().uri(new URI("/
flixmash/rest/v1/movies/popularMovies")).build();
response = client.executeWithLoadBalancer(request);
String movies = response.getEntity(String.class);
return movies;
} catch (Exception exc) {
throw new RuntimeException("Exception", exc);
} finally {
if (response!=null){
//hand the connection back to the pool
response.close();
}
}
52. Archaius: Configuration (properties) as a Service
•
Property Driven Development
for (int i=0; I < numRowsProperty.get(); i++){
fetchMovieForRow(i, numMoviePerRowProperty.get());
}
@stonse
69. Simian Army: Availability/Resiliency as a Service
•
Chaos Monkey
• Kills instances
•
Janitor Monkey
• Clean up unused Resources
•
Conformity Monkey
• Confirms adherence to Best
Practices
•
Others (yet to be open sourced)
• Latency Monkey
• Chaos Kong
• …
@stonse
75. Workshop …
Hands On: Building Hello Netflix OSS application
•
Concepts
•
•
Configuration
•
Build Script (gradle)
•
Application Container/Bootstrap
•
JSR-311 Web Resource
•
Properties via Archaius
•
Metrics via Servo
•
Dependency Injection via Governator/Guice
•
RPC calls via Ribbon/Eureka
•
Resiliency via Hystrix (wrappers on top of Ribbon)
•
Invoking a Mid-tier Web Service
•
@stonse
Project Layout
AdminConsole (port 8077)
76. Workshop …
Hands On: Building Hello Netflix OSS application
•
@stonse
Instructions at http://bit.ly/1dlDyVC
80. JSR-311 Web Resource
1. Hello World Resource -> https://netflix.box.com/s/
nyspqi1an095d4p5xd7k
2. Flixmash Resource -> https://netflix.box.com/s/
nb1nd7bqk7qcmxnwuol0
@Path("/flixmash")
public class FlixmashResource {
@GET
@Path("popularMovies")
@Produces({MediaType.APPLICATION_JSON})
public Response movies() {
// Start timer
Stopwatch stopwatch = getMoviesTimer.start();
JSONObject response = new JSONObject();
try {
getMoviesCounter.increment();
response.put("Movies",
flixmashManager.getPopularMovies()); // obtain movies from our
flixMovies component
return Response.ok(response.toString()).build();
} catch (JSONException e) {
getMoviesErrorCounter.increment();
logger.error("Error creating json response.", e);
return
Response.status(Response.Status.INTERNAL_SERVER_ERROR).build
();
} finally {
stopwatch.stop();
}
}
81. ARCHAIUS: PROPERTIES
flixmash.popularMovieList=Lord of the Ring,Matrix,Harry Potter,Gravity
private static final DynamicStringListProperty popularMovieList
= new DynamicStringListProperty("flixmash.popularMovieList",
(List<String>) null);
List<String> movies = popularMovieList.get();
85. Takeaways …
•
Cloud Computing and Cloud based Services requires embracing Cloud Native
- Adrian Cockroft (@adrianco)
•
NetflixOSS is here to help!
• You can build your own custom PaaS the Netflix Way!
http://netflix.github.io
@stonse
Yes, we are Hiring!