0%

Use Python microservices to craft applications that are built as small standard units using proven best practices and avoiding common errors

Key Features

  • Become well versed with the fundamentals of building, designing, testing, and deploying Python microservices
  • Identify where a monolithic application can be split, how to secure it, and how to scale it once ready for deployment
  • Use the latest framework based on asynchronous programming to write effective microservices with Python

Book Description

The small scope and self-contained nature of microservices make them faster, cleaner, and more scalable than code-heavy monolithic applications. However, building microservices architecture that is efficient as well as lightweight into your applications can be challenging due to the complexity of all the interacting pieces.

Python Microservices Development, Second Edition will teach you how to overcome these issues and craft applications that are built as small standard units using proven best practices and avoiding common pitfalls. Through hands-on examples, this book will help you to build efficient microservices using Quart, SQLAlchemy, and other modern Python tools

In this updated edition, you will learn how to secure connections between services and how to script Nginx using Lua to build web application firewall features such as rate limiting. Python Microservices Development, Second Edition describes how to use containers and AWS to deploy your services. By the end of the book, you'll have created a complete Python application based on microservices.

What you will learn

  • Explore what microservices are and how to design them
  • Configure and package your code according to modern best practices
  • Identify a component of a larger service that can be turned into a microservice
  • Handle more incoming requests, more effectively
  • Protect your application with a proxy or firewall
  • Use Kubernetes and containers to deploy a microservice
  • Make changes to an API provided by a microservice safely and keep things working
  • Identify the factors to look for to get started with an unfamiliar cloud provider

Who this book is for

This book is for developers who want to learn how to build, test, scale, and manage Python microservices. Readers will require basic knowledge of the Python programming language, the command line, and HTTP-based application principles. No prior experience of writing microservices in Python is assumed.

Table of Contents

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Get in touch
  2. Understanding Microservices
    1. The origins of service-oriented architecture
    2. The monolithic approach
    3. The microservice approach
    4. Microservice benefits
    5. Separation of concerns
    6. Smaller projects
    7. Scaling and deployment
    8. Pitfalls of microservices
    9. Illogical splitting
    10. More network interactions
    11. Data storing and sharing
    12. Compatibility issues
    13. Testing
    14. Implementing microservices with Python
    15. How web services work
    16. The WSGI standard
    17. Workers, threads, and synchronicity
    18. A worker pool approach
    19. Being asynchronous
    20. Twisted, Tornado, Greenlets, and Gevent
    21. Asynchronous Python
    22. Language performance
    23. Summary
  3. Discovering Quart
    1. Making sure we have Python
    2. How Quart handles requests
    3. Routing
    4. Variables and converters
    5. The url_for function
    6. Request
    7. Response
    8. Quart's built-in features
    9. The session object
    10. Globals
    11. Signals
    12. Extensions and middleware
    13. Templates
    14. Configuration
    15. Blueprints
    16. Error handling
    17. Custom error handler
    18. A microservice skeleton
    19. Summary
  4. Coding, Testing, and Documentation: the Virtuous Cycle
    1. Different kinds of tests
    2. Unit tests
    3. Functional tests
    4. Integration tests
    5. Load tests
    6. End-to-end tests
    7. Using pytest and tox
    8. Developer documentation
    9. Tools for documentation
    10. Version control
    11. Continuous Integration and Continuous Deployment
    12. GitHub Actions
    13. Documentation
    14. Coveralls
    15. Badges
    16. Summary
  5. Designing Jeeves
    1. The Jeeves bot
    2. User stories
    3. Monolithic design
    4. Model
    5. View and template
    6. A human-readable view
    7. Slack workspaces
    8. Taking actions
    9. OAuth tokens
    10. Authentication and authorization
    11. Background tasks
    12. Putting together the monolithic design
    13. Summary
  6. Splitting the Monolith
    1. Identifying potential microservices
    2. Code complexity and maintenance
    3. Metrics and Monitoring
    4. Logging
    5. Splitting a Monolith
    6. Feature Flags
    7. Refactoring Jeeves
    8. Workflow
    9. Summary
  7. Interacting with Other Services
    1. Calling other web resources
    2. Finding out where to go
    3. Environment variables
    4. Service discovery
    5. Transferring data
    6. HTTP cache headers
    7. GZIP compression
    8. Protocol Buffers
    9. MessagePack
    10. Putting it together
    11. Asynchronous messages
    12. Message queue reliability
    13. Basic queues
    14. Topic exchanges and queues
    15. Publish/subscribe
    16. Putting it together
    17. Testing
    18. Using OpenAPI
    19. Summary
  8. Securing Your Services
    1. The OAuth2 protocol
    2. X.509 certificate-based authentication
    3. Token-based authentication
    4. The JWT standard
    5. PyJWT
    6. Using a certificate with JWT
    7. The TokenDealer microservice
    8. The OAuth implementation
    9. Using TokenDealer
    10. Securing your code
    11. Limiting your application scope
    12. Untrusted incoming data
    13. Redirecting and trusting queries
    14. Sanitizing input data
    15. Using Bandit linter
    16. Dependencies
    17. Web application firewall
    18. OpenResty: Lua and nginx
    19. Rate and concurrency limiting
    20. Other OpenResty features
    21. Summary
  9. Making a Dashboard
    1. Building a ReactJS dashboard
    2. The JSX syntax
    3. React components
    4. Pre-processing JSX
    5. ReactJS and Quart
    6. Cross-origin resource sharing
    7. Authentication and authorization
    8. A note about Micro Frontends
    9. Getting the Slack token
    10. JavaScript authentication
    11. Summary
  10. Packaging and Running Python
    1. The packaging toolchain
    2. A few definitions
    3. Packaging
    4. The setup.py file
    5. The requirements.txt file
    6. The MANIFEST.in file
    7. Versioning
    8. Releasing
    9. Distributing
    10. Running all microservices
    11. Process management
    12. Summary
  11. Deploying on AWS
    1. What is Docker?
    2. Introduction to Docker
    3. Running Quart in Docker
    4. Docker-based deployments
    5. Terraform
    6. Service discovery
    7. Docker Compose
    8. Docker Swarm
    9. Kubernetes
    10. Summary
  12. What's Next?
    1. Automation
    2. Scaling
    3. Content Delivery Networks
    4. Multi-cloud deployments
    5. Lambda Functions
    6. Expanding monitoring
    7. Making promises
    8. Summary
  13. Other Books You May Enjoy
  14. Index
3.149.230.44