SlideShare une entreprise Scribd logo
1  sur  38
Télécharger pour lire hors ligne
Mesos & Django
(and Aurora,
CircleCI)
Python Ireland July 2015
michael.twomey@udemy.com
@micktwomey
Who is this talk for?
• The curious
• Folks who look after more than a handful of
machines and services
• You have a "platform team" or "devops" (what
does that even mean?)
• Get woken at 3am to fix things
Warning
Precious snowflake boxes
• Lots of different machines (web-01, redis-03,
dont-delete-web-99, memcached4)
• No one remembers who or how the celery
box was setup but we can't build a new one
• My fabric scripts need unit tests
• I really want to try that new framework but that
means finding a box, I know that web server
doesn't have much traffic...
• Sod it, lets use Heroku!
No, really, use Heroku !
I need to manage
lots of machines
and those
annoying "CI"
developers
I know I'll use Mesos!
Now you have
two problems!
No, wait, wrong analogy
A distributed
systems kernel
— mesos.apache.org
Wat?
A programmable
monit/
supervisor/
upstart for all
the things
Wat?
Makes it much
easier to
manage lots of
processes
1. Install it on all your
machines
2. Run a Mesos framework (or
two)
3. Profit!
Step 1: Deploy Mesos
• Now you've got a hundred, easily deployed
machines running Mesos slaves
• Now what?
Step 2: Add a Framework
What's a Framework?
The brains of the operation
™Apache
Aurora
• Transactional deployments
• Process management
• Scaling
• Mix production and development
• "Cron" jobs
• Did I mention transactional deployments
Acaversity
A simple Django app
I mean, really simple
def index(request):
version = 3
html = ("<html><body>"
"<h1>Hello</h1>"
"<p>What do you want to learn today?</p>"
"<p>Version {}</p></body></html>").format(version)
return HttpResponse(html)
def healthcheck(request):
return JsonResponse({"ok": True})
Acaversity build
• Django app
• Build and test on CircleCI
• Upload a slug to S3
Acaversity deployment
• Deploy using Aurora
• Fetches slug
• Unpacks
• Starts process
• Health checks to victory
• Registers with Zookeeper
Whoops
Circle of Life
acaversity.aurora
fetch = Process(...)
setup = Process(...)
start = Process(...)
django_task = SequentialTask(...)
jobs = [
Service(...)
]
1. Fetch the slug
fetch = Process(
name = 'fetch',
cmdline = ('export AWS_ACCESS_KEY_ID=... '
'export AWS_SECRET_ACCESS_KEY=... '
'env '
'; aws s3 cp s3://... slug.tar.gz '
'&& tar -zxf slug.tar.gz'
),
)
Bonus tip: Use vault for your
secrets
2. Run the setup script
setup = Process(
name = 'setup.sh',
cmdline = 'bash slug/scripts/setup.sh',
)
Start the process
start = Process(
name = 'start.sh',
cmdline = ('bash slug/scripts/start.sh '
'--http :{{thermos.ports[http]}} '
'--http :{{thermos.ports[health]}}')
)
3. Define the overall task
django_task = SequentialTask(
processes = [fetch, setup, start],
resources = Resources(cpu = 1, ram = 100*MB, disk=100*MB)
)
Side note: resources
Resources(cpu = 1, ram = 100*MB, disk=100*MB)
• Asks for a Mesos slave which can give a
logical core, 100MB of RAM and 100MB of
disk.
• Runs in container and restricts to these
resources
• e.g. kills your process if it starts spewing
data to disk
• CPU scheduler restricts run time
4. Create a Service
update_config = UpdateConfig(watch_secs=45, batch_size=2)
health_check_config = HealthCheckConfig(
initial_interval_secs=15, interval_secs=10,
expected_response='{"ok": true}',
)
announcer_config = Announcer()
jobs = [
Service(cluster = 'devcluster',
environment = 'devel',
role = 'www-data',
name = 'acaversity',
instances = 4,
task = django_task,
update_config = update_config,
health_check_config = health_check_config,
announce = announcer_config,
constraints = {
'host': 'limit:10',
})]
Bonus: What would the
Docker version look like?
jobs = [
Service(cluster = 'devcluster',
environment = 'devel',
role = 'www-data',
name = 'acaversity-docker',
task = django_docker,
container = Container(
docker = Docker(
image = 'acaversity:1.2'
)))]
Deploying
aurora update start 
devcluster/www-data/devel/acaversity 
acaversity.aurora
Scaling up
instances = 10
aurora update start 
devcluster/www-data/devel/acaversity 
acaversity.aurora
Question: What does it do with the old intances?
Cron Jobs
jobs = [
Job(
cluster = 'devcluster',
role = 'www-data',
environment = 'test',
name = 'cron_hello_world',
cron_schedule = '*/5 * * * *',
task = SimpleTask(
'cron_hello_world',
'echo "Hello world from cron"'),
),
]
Time to anger
the demo gods
Thank You!
PS: Going to
Ely's
PPS: Udemy is hiring
PPPS: Pick up one chair
each and take it back to
the middle

Contenu connexe

Dernier

Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 

Dernier (20)

Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Mesos & Django (and Aurora and CircleCI)

  • 1. Mesos & Django (and Aurora, CircleCI) Python Ireland July 2015 michael.twomey@udemy.com @micktwomey
  • 2. Who is this talk for? • The curious • Folks who look after more than a handful of machines and services • You have a "platform team" or "devops" (what does that even mean?) • Get woken at 3am to fix things
  • 4.
  • 5. Precious snowflake boxes • Lots of different machines (web-01, redis-03, dont-delete-web-99, memcached4) • No one remembers who or how the celery box was setup but we can't build a new one • My fabric scripts need unit tests • I really want to try that new framework but that means finding a box, I know that web server doesn't have much traffic... • Sod it, lets use Heroku!
  • 6. No, really, use Heroku !
  • 7. I need to manage lots of machines and those annoying "CI" developers I know I'll use Mesos!
  • 8. Now you have two problems! No, wait, wrong analogy
  • 10. Wat?
  • 12. Makes it much easier to manage lots of processes 1. Install it on all your machines 2. Run a Mesos framework (or two) 3. Profit!
  • 13.
  • 14. Step 1: Deploy Mesos • Now you've got a hundred, easily deployed machines running Mesos slaves • Now what?
  • 15. Step 2: Add a Framework What's a Framework? The brains of the operation
  • 16.
  • 18. Aurora • Transactional deployments • Process management • Scaling • Mix production and development • "Cron" jobs • Did I mention transactional deployments
  • 20. I mean, really simple def index(request): version = 3 html = ("<html><body>" "<h1>Hello</h1>" "<p>What do you want to learn today?</p>" "<p>Version {}</p></body></html>").format(version) return HttpResponse(html) def healthcheck(request): return JsonResponse({"ok": True})
  • 21. Acaversity build • Django app • Build and test on CircleCI • Upload a slug to S3
  • 22. Acaversity deployment • Deploy using Aurora • Fetches slug • Unpacks • Starts process • Health checks to victory • Registers with Zookeeper
  • 23.
  • 26. acaversity.aurora fetch = Process(...) setup = Process(...) start = Process(...) django_task = SequentialTask(...) jobs = [ Service(...) ]
  • 27. 1. Fetch the slug fetch = Process( name = 'fetch', cmdline = ('export AWS_ACCESS_KEY_ID=... ' 'export AWS_SECRET_ACCESS_KEY=... ' 'env ' '; aws s3 cp s3://... slug.tar.gz ' '&& tar -zxf slug.tar.gz' ), ) Bonus tip: Use vault for your secrets
  • 28. 2. Run the setup script setup = Process( name = 'setup.sh', cmdline = 'bash slug/scripts/setup.sh', )
  • 29. Start the process start = Process( name = 'start.sh', cmdline = ('bash slug/scripts/start.sh ' '--http :{{thermos.ports[http]}} ' '--http :{{thermos.ports[health]}}') )
  • 30. 3. Define the overall task django_task = SequentialTask( processes = [fetch, setup, start], resources = Resources(cpu = 1, ram = 100*MB, disk=100*MB) )
  • 31. Side note: resources Resources(cpu = 1, ram = 100*MB, disk=100*MB) • Asks for a Mesos slave which can give a logical core, 100MB of RAM and 100MB of disk. • Runs in container and restricts to these resources • e.g. kills your process if it starts spewing data to disk • CPU scheduler restricts run time
  • 32. 4. Create a Service update_config = UpdateConfig(watch_secs=45, batch_size=2) health_check_config = HealthCheckConfig( initial_interval_secs=15, interval_secs=10, expected_response='{"ok": true}', ) announcer_config = Announcer() jobs = [ Service(cluster = 'devcluster', environment = 'devel', role = 'www-data', name = 'acaversity', instances = 4, task = django_task, update_config = update_config, health_check_config = health_check_config, announce = announcer_config, constraints = { 'host': 'limit:10', })]
  • 33. Bonus: What would the Docker version look like? jobs = [ Service(cluster = 'devcluster', environment = 'devel', role = 'www-data', name = 'acaversity-docker', task = django_docker, container = Container( docker = Docker( image = 'acaversity:1.2' )))]
  • 34. Deploying aurora update start devcluster/www-data/devel/acaversity acaversity.aurora
  • 35. Scaling up instances = 10 aurora update start devcluster/www-data/devel/acaversity acaversity.aurora Question: What does it do with the old intances?
  • 36. Cron Jobs jobs = [ Job( cluster = 'devcluster', role = 'www-data', environment = 'test', name = 'cron_hello_world', cron_schedule = '*/5 * * * *', task = SimpleTask( 'cron_hello_world', 'echo "Hello world from cron"'), ), ]
  • 37. Time to anger the demo gods
  • 38. Thank You! PS: Going to Ely's PPS: Udemy is hiring PPPS: Pick up one chair each and take it back to the middle