0% found this document useful (0 votes)
15 views8 pages

19deploying Python Code

Uploaded by

tej desai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views8 pages

19deploying Python Code

Uploaded by

tej desai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Department of Mathematical and Physical Sciences

Concordia University of Edmonton

Deploying Python code


Deploying Python code
 A deployment environment is a configuration in which a
program runs. Every program has at least one deployment
environment: the production environment.
 The goal of writing a program in the first place is to put it to
work in the production environment and achieve some kind
of outcome.
 Writing or modifying a program requires being able to run it
on the computer you use for developing.
 The configuration of your development environment may be
very different from that of your production environment.

2
Aspect of code deployment
 What are the main challenges in deploying the code to
remote environments?
 How to build applications in Python that are easily
deployable
 How to reload web services without downtime
 How to leverage a Python packaging ecosystem in code
deployment
 How to properly monitor and instrument code that runs
remotely

3
The twelve-factor app
 Website: https://12factor.net/
 Software is commonly delivered as a service: called web
apps, or software-as-a-service.
 The twelve-factor app is a methodology for building
software-as-a-service, see introduction: https://12factor.net/
 The twelve-factor methodology can be applied to apps
written in any programming language, and which use any
combination of backing services (database, queue, memory
cache, etc).

4
The twelve-factor app https://12factor.net/

1. Code base: One code base tracked in revision control and


many deploys
2. Dependencies: Explicitly declare and isolate dependencies
3. Config: Store configurations in the environment
4. Backing services: Treat backing services as attached
resources
5. Build, release, run: Strictly separate build and run stages
6. Processes: Execute the app as one or more stateless
processes

5
The twelve-factor app https://12factor.net/

7. Port binding: Export services via port binding


8. Concurrency: Scale out via the process model
9. Disposability: Maximize robustness with fast startup and
graceful shutdown
10. Dev/prod parity: Keep development, staging, and
production as similar as possible
11. Logs: Treat logs as event streams
12. Admin processes: Run administration/management tasks as
one-off processes

6
Deployment automation
 Application containerization (Docker and similar
technologies)
 Modern software provisioning tools (for example, Puppet,
Chef, Ansible, and Salt)
 Infrastructure management systems (for example, Terraform
and SaltStack)
 Container orchestrations systems in the style of Kubernetes
that allow you to leverage Docker containers for fast,
maintainable, scalable, and reproducible environments
 Fabric is simple and easy to grasp, so it is a great tool to
introduce someone to the concept of automation

7
Things to Remember
 Programs often need to run in multiple deployment
environments that each have unique assumptions and
configurations.
 You can tailor a module’s contents to different deployment
environments by using normal Python statements in module
scope.
 Module contents can be the product of any external
condition, including host introspection through the sys and
os modules.

You might also like