Python Microservices Development: Build efficient and lightweight microservices using the Python tooling ecosystem, 2nd Edition
- Length: 280 pages
- Edition: 2
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2021-10-11
- ISBN-10: 1801076308
- ISBN-13: 9781801076302
- Sales Rank: #1220237 (See Top 100 Books)
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 Content
- Section 1: Python Web Services – Understanding Microservices
- Discovering Quart
- Coding, Testing, and Documenting – the Virtuous Cycle
- Section 2: Designing Jeeves
- Splitting the Monolith
- Interacting with Other Services
- Securing Your Services
- Making a Dashboard
- Section 3: Deployment, Running, and Scaling -Packaging and Running Runnerly
- Deploying Containers
- What’s next?
Preface Who this book is for What this book covers To get the most out of this book Get in touch Understanding Microservices The origins of service-oriented architecture The monolithic approach The microservice approach Microservice benefits Separation of concerns Smaller projects Scaling and deployment Pitfalls of microservices Illogical splitting More network interactions Data storing and sharing Compatibility issues Testing Implementing microservices with Python How web services work The WSGI standard Workers, threads, and synchronicity A worker pool approach Being asynchronous Twisted, Tornado, Greenlets, and Gevent Asynchronous Python Language performance Summary Discovering Quart Making sure we have Python How Quart handles requests Routing Variables and converters The url_for function Request Response Quart's built-in features The session object Globals Signals Extensions and middleware Templates Configuration Blueprints Error handling Custom error handler A microservice skeleton Summary Coding, Testing, and Documentation: the Virtuous Cycle Different kinds of tests Unit tests Functional tests Integration tests Load tests End-to-end tests Using pytest and tox Developer documentation Tools for documentation Version control Continuous Integration and Continuous Deployment GitHub Actions Documentation Coveralls Badges Summary Designing Jeeves The Jeeves bot User stories Monolithic design Model View and template A human-readable view Slack workspaces Taking actions OAuth tokens Authentication and authorization Background tasks Putting together the monolithic design Summary Splitting the Monolith Identifying potential microservices Code complexity and maintenance Metrics and Monitoring Logging Splitting a Monolith Feature Flags Refactoring Jeeves Workflow Summary Interacting with Other Services Calling other web resources Finding out where to go Environment variables Service discovery Transferring data HTTP cache headers GZIP compression Protocol Buffers MessagePack Putting it together Asynchronous messages Message queue reliability Basic queues Topic exchanges and queues Publish/subscribe Putting it together Testing Using OpenAPI Summary Securing Your Services The OAuth2 protocol X.509 certificate-based authentication Token-based authentication The JWT standard PyJWT Using a certificate with JWT The TokenDealer microservice The OAuth implementation Using TokenDealer Securing your code Limiting your application scope Untrusted incoming data Redirecting and trusting queries Sanitizing input data Using Bandit linter Dependencies Web application firewall OpenResty: Lua and nginx Rate and concurrency limiting Other OpenResty features Summary Making a Dashboard Building a ReactJS dashboard The JSX syntax React components Pre-processing JSX ReactJS and Quart Cross-origin resource sharing Authentication and authorization A note about Micro Frontends Getting the Slack token JavaScript authentication Summary Packaging and Running Python The packaging toolchain A few definitions Packaging The setup.py file The requirements.txt file The MANIFEST.in file Versioning Releasing Distributing Running all microservices Process management Summary Deploying on AWS What is Docker? Introduction to Docker Running Quart in Docker Docker-based deployments Terraform Service discovery Docker Compose Docker Swarm Kubernetes Summary What's Next? Automation Scaling Content Delivery Networks Multi-cloud deployments Lambda Functions Expanding monitoring Making promises Summary Other Books You May Enjoy Index
Donate to keep this site alive
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Python Microservices Development: Build efficient and lightweight microservices using the Python tooling ecosystem, 2nd Edition
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.