python on cloud foundry

20
1 © Copyright 2014 Pivotal. All rights reserved. Python on Cloud Foundry Ian Huston, Data Scientist

Upload: ian-huston

Post on 02-Jul-2015

1.028 views

Category:

Technology


8 download

DESCRIPTION

Presented at PyData NY 2014 Resources: http://www.ianhuston.net/2014/11/python-on-cloud-foundry/ As a data scientist I frequently need to create web apps to provide interactive functionality, deliver data APIs or simply publish results. It is now easier than ever to deploy your data driven web app by using cloud based application platforms to do the heavy lifting. Cloud Foundry is an open source public and private cloud platform that supports Python based applications (along with other languages) and enables simple app deployment, scaling and connectivity to data services like PostgreSQL, Redis and Cassandra. To make use of the full PyData stack I have created a Heroku-style buildpack which uses conda for package management. This means for example that you can get a private IPython Notebook server up and running in seconds. In this talk I want to show you how to deploy your first app using Cloud Foundry, connect to databases and other data services, use PyData packages with a Heroku-style buildpack, find public and private Cloud Foundry installation options.

TRANSCRIPT

Page 1: Python on Cloud Foundry

@ianhuston 1 © Copyright 2014 Pivotal. All rights reserved. 1 © Copyright 2014 Pivotal. All rights reserved.

Python on Cloud Foundry

Ian Huston, Data Scientist

Page 2: Python on Cloud Foundry

@ianhuston 2 © Copyright 2014 Pivotal. All rights reserved.

Who am I?

�  Ian Huston

� @ianhuston

� github.com/ihuston

� www.ianhuston.net

� Talk resources: http://tinyurl.com/pythonCF

� Data Scientist

� Use PyData stack for predictive analytics and machine learning

� Previously a theoretical physicist using Python for numerical simulations & HPC

Page 3: Python on Cloud Foundry

@ianhuston 3 © Copyright 2014 Pivotal. All rights reserved.

What is Cloud Foundry?

http://cloudfoundry.org

Open Source Cloud Platform

Simple App Deployment, Scaling & Availability

Page 4: Python on Cloud Foundry

@ianhuston 4 © Copyright 2014 Pivotal. All rights reserved.

Cloud Foundry Foundation: Industry Standard

Gold

Silver

Page 5: Python on Cloud Foundry

@ianhuston 5 © Copyright 2014 Pivotal. All rights reserved.

CF for data scientists & developers Easily deploy your web app

cf  push  Scale up and out quickly

cf  scale  myapp  –i  5  –m  1G  Create and bind services

cf  bind-­‐service  myapp  redis  

 

Page 6: Python on Cloud Foundry

@ianhuston 6 © Copyright 2014 Pivotal. All rights reserved.

mod proxy

1.  The platform takes care of all the steps on the left automatically

50 Configuration Touches

1.  Register Hostname with DNS (1) 2.  Configure F5 Load Balancing Group (2) 3.  Configure Apache HTTPd Worker Pool (4) 4.  Configure mod_proxy Connector Routing (4) 5.  Configure Tomcat Connector Pool (40)

1 Configuration Touch

1 2 4 4 40 1

Cloud Foundry: From 50 touch points to 1

Page 7: Python on Cloud Foundry

@ianhuston 7 © Copyright 2014 Pivotal. All rights reserved. 7 © Copyright 2014 Pivotal. All rights reserved.

Python & CF

Page 8: Python on Cloud Foundry

@ianhuston 8 © Copyright 2014 Pivotal. All rights reserved.

Python on Cloud Foundry

� First class language (with Go, Java, Ruby, Node.js, PHP)

� Automatic app type detection

� Buildpack takes care of –  Installing Python interpreter –  Installing packages in requirements.txt using pip –  Starting web app as requested (e.g. python myapp.py)

Page 9: Python on Cloud Foundry

@ianhuston 9 © Copyright 2014 Pivotal. All rights reserved.

Simple Flask App Demo � Simple one page “Hello World” web app

� Video: https://www.youtube.com/watch?v=QOfD6tnoAB8

� Demonstrates: –  Installation of requirements –  Scaling properties

� Need to Provide: –  App files –  Dependencies listed in requirements.txt file –  Optional manifest.yml file with configuration for deployment

Page 10: Python on Cloud Foundry

@ianhuston 10 © Copyright 2014 Pivotal. All rights reserved.

Data Services

� Easy to bind and scale services –  Databases, NoSQL, message queues etc. $  cf  create-­‐service  rediscloud  PLAN_NAME  INSTANCE_NAME  $  cf  bind-­‐service  APP_NAME  INSTANCE_NAME  

� Details provided in VCAP_APP_SERVICES env variable: {  "rediscloud":  [          {  "name":  "rediscloud-­‐42",  "label":  "rediscloud",  "plan":  "20mb",              "credentials":  {  "port"":  "6379",    

 "hostname":  "pub-­‐redis-­‐6379.us-­‐east-­‐1-­‐2.3.ec2.redislabs.com",                  "password":  "your_redis_password”    }    }  ]  }  

Page 11: Python on Cloud Foundry

@ianhuston 11 © Copyright 2014 Pivotal. All rights reserved.

Services now available These are available on Pivotal CF (Pivotal’s packaged Cloud Foundry offering).

See http://run.pivotal.io for the services available on Pivotal Web Services.

Page 12: Python on Cloud Foundry

@ianhuston 12 © Copyright 2014 Pivotal. All rights reserved.

PyData stack on CF: conda  +    

•  Use (mini)conda to provide Python & package installation

•  Quickly install needed PyData packages •  Can even provision your own IPython notebook

server [at your own risk!]

CF Buildpack: https://github.com/ihuston/python-conda-buildpack

Page 13: Python on Cloud Foundry

@ianhuston 13 © Copyright 2014 Pivotal. All rights reserved. 13 © Copyright 2014 Pivotal. All rights reserved.

Why?

Page 14: Python on Cloud Foundry

@ianhuston 14 © Copyright 2014 Pivotal. All rights reserved.

Benefits for Data Scientists

� Easy to get web apps up and running

� Create and bind to your favourite data services

� Don’t get locked in to one cloud provider

� Python is officially supported

Page 15: Python on Cloud Foundry

@ianhuston 15 © Copyright 2014 Pivotal. All rights reserved.

Try Cloud Foundry today!

Pivotal Web Services: http://run.pivotal.io IBM Bluemix: http://bluemix.net Anynines: http://anynines.com

HP Helion: http://horizon.hpcloud.com

Page 16: Python on Cloud Foundry

@ianhuston 16 © Copyright 2014 Pivotal. All rights reserved.

More info and resources

� Material for this talk: http://tinyurl.com/pythonCF

� Cloud Foundry: http://cloudfoundry.org

� Flask Mega Meta Tutorial for DS: http://tinyurl.com/flaskDS

� Twelve Factor Apps: http://12factor.net/

� Meetups: http://cloud-foundry.meetup.com/

Page 17: Python on Cloud Foundry

@ianhuston 17 © Copyright 2014 Pivotal. All rights reserved. 17 © Copyright 2014 Pivotal. All rights reserved.

Appendix Docker & Cloud Foundry

Page 18: Python on Cloud Foundry

@ianhuston 18 © Copyright 2014 Pivotal. All rights reserved.

Docker joins the Cloud Foundry Foundation in May 2014 to support Cloud Foundry open governance and advance the state of containers in Platform as a Service

CF and Docker

Page 19: Python on Cloud Foundry

@ianhuston 19 © Copyright 2014 Pivotal. All rights reserved.

Docker Benefit: Customize More Layers of the App

runtime layer

OS image

application layer

Docker

system brings fixed host OS Kernel

* Devs may bring a custom buildpack

runtime layer*

OS image

application layer

Buildpack

system brings fixed host OS Kernel

App container

System Provides

Dev Provides

Page 20: Python on Cloud Foundry

@ianhuston 20 © Copyright 2014 Pivotal. All rights reserved.

Coming soon to Cloud Foundry � Planned to support Cloud Foundry apps from: –  Linux Buildpacks –  Windows .NET Buildpacks powered by Iron Foundry –  Docker images

� Docker applications will work similar to apps from buildpacks –  Same scaling & services bindings, same CLI commands push etc