ENGLISH

Hands-On Enterprise Application Development with Python: Design data-intensive Application with Python 3

Book information

Publisher
Packt Publishing
Year
2018
ISBN
9781789532364, 1789532361
Language
english
Format
PDF
Filesize
3 MB (2827032 bytes)
Pages
374\362
Time added
2021-12-14 16:00:42

Description

Architect scalable, reliable, and maintainable applications for enterprises with Python Key Features Explore various Python design patterns used for enterprise software development Apply best practices for testing and performance optimization to build stable applications Learn about different attacking strategies used on enterprise applications and how to avoid them Book Description Dynamically typed languages like Python are continuously improving. With the addition of exciting new features and a wide selection of modern libraries and frameworks, Python has emerged as an ideal language for developing enterprise applications. Hands-On Enterprise Application Development with Python will show you how to build effective applications that are stable, secure, and easily scalable. The book is a detailed guide to building an end-to-end enterprise-grade application in Python. You will learn how to effectively implement Python features and design patterns that will positively impact your application lifecycle. The book also covers advanced concurrency techniques that will help you build a RESTful application with an optimized frontend. Given that security and stability are the foundation for an enterprise application, you'll be trained on effective testing, performance analysis, and security practices, and understand how to embed them in your codebase during the initial phase. You'll also be guided in how to move on from a monolithic architecture to one that is service oriented, leveraging microservices and serverless deployment techniques. By the end of the book, you will have become proficient at building efficient enterprise applications in Python. What you will learn Understand the purpose of design patterns and their impact on application lifecycle Build applications that can handle large amounts of data-intensive operations Uncover advanced concurrency techniques and discover how to handle a large number of requests in production Optimize frontends to improve the client-side experience of your application Effective testing and performance profiling techniques to detect issues in applications early in the development cycle Build applications with a focus on security Implement large applications as microservices to improve scalability Who this book is for If you're a developer who wants to build enterprise-grade applications, this book is for you. Basic to intermediate-level of programming experience with Python and database systems is required to understand the concepts covered in this book. Table of Contents Using Python for Enterprise Design Patterns: Making a Choice Building for Large Scale Database Operations Dealing with Concurrency Building for Large Scale Request Handling Example: Building BugZot Building Optimized Frontends Writing Testable Code Profiling Applications for Performance Securing Your Application Taking the Microservices Approach Testing and Tracing in Microservices Going Serverless Deploying to the Cloud Enterprise Application Integration and its Patterns Microservices and Enterprise Application Integration Cover Title Page Copyright and Credits About Packt Contributors Table of Contents Preface Chapter 1: Using Python for Enterprise Technical requirements Recent developments in Python Dropping backward compatibility It's all Unicode Support for type hinting Where Python shines The requirements of enterprise IT Python in the enterprise ecosystem Introducing BugZot – a RESTful bug tracker Gathering requirements before development Asking for the user requirements Categorizing the requirements Prioritizing the requirements Generating the software requirement specification document Summary Questions Further reading Chapter 2: Design Patterns – Making a Choice Technical Requirements Design patterns Classification of design patterns Defining the choice of design patterns Object-oriented Python The basic OOP principles Encapsulation Composition Inheritance Multiple inheritance in Python Method resolution order in multiple inheritance Utilizing mixins Abstract base classes Metaclasses The Singleton pattern The __call__ magic method The Factory pattern The Model-View-Controller pattern Controller Model View Summary Questions Chapter 3: Building for Large-Scale Database Operations Technical requirements Database and object relational mappers Setting up SQLAlchemy Building optimal database models Issues with our model definition Optimizing our models Taking advantage of indexes Maintaining database consistency Utilizing transactions to maintain consistency Understanding lazy loading versus eager loading Using relationships Lazy loading Eager loading Optimizing data loading Utilizing caching Caching at the database level Caching at the block level Using user-level caching Summary Questions Chapter 4: Dealing with Concurrency Technical requirements The need for concurrency Concurrency in GUI applications Concurrency in enterprise applications Concurrent programming with Python Concurrency with multithreading Thread synchronization Re-entrant locks Condition variables Common pitfalls with multithreading Race conditions Deadlocks The story of GIL Concurrency with multiprocessing Python multiprocessing module Synchronizing processes Summary Questions Chapter 5: Building for Large-Scale Request Handling Technical requirements The problems of accommodating increased concurrency The multiple options to scale up Engineering the application for scalability Controlling the concurrency Using thread pools for handling incoming connections Asynchronous programming with AsyncIO AsyncIO terminology Event loop Co-routines Tasks Writing a simple Python AsyncIO program Implementing a simple socket server with AsyncIO Boosting the application concurrency Running behind a reverse proxy Improved security Improved connection handling Resource caching Serving static resources Summary Questions Chapter 6: Example – Building BugZot Technical requirements Defining the requirements Entering the development phase Setting up the development environment Setting up the database Setting up the virtual environment Structuring our project Initializing the Flask project Creating the configuration Developing database models Migrating the database models Building the views Developing the index view Getting the index view to render Building the user registration view Deploying for concurrent access Setting up Gunicorn Setting up Nginx as reverse proxy Establishing communication between Nginx and Gunicorn Summary Questions Chapter 7: Building Optimized Frontends Technical requirements The need for optimizing frontends Components of an optimized frontend What causes frontend issues Optimizing the frontend Optimizing resources Fetching CSS in parallel by avoiding CSS imports Bundling JavaScript Utilizing client-side caching Setting application-wide cache control Setting request level cache control Utilizing web storage Working with local web storage Working with session storage Summary Questions Chapter 8: Writing Testable Code Technical requirements The importance of testing The different kinds of testing Unit testing Integration testing Building an application with testing in mind Test-driven development Writing unit tests Writing unit tests with Python unittest Writing unit tests with pytest Let's set up pytest Writing our first test with pytest Writing functional tests with pytest Summary Questions Chapter 9: Profiling Applications for Performance Technical requirements Behind the scenes of performance bottlenecks Looking at the causes of performance bottlenecks Probing an application for performance issues Writing performance benchmarks Writing our first benchmark Writing an API benchmark Doing component-level performance analysis Measuring slow operations with timeit Profiling with cProfile Profiling for memory usage with memory_profiler Collecting live performance data Logging performance metrics Avoiding performance bottlenecks Summary Questions Chapter 10: Securing Your Application Technical requirements Enterprise application security The importance of enterprise security Challenges in system security Taking a look at the attack vectors Security issues with native applications Security issues with web applications Security anti-patterns Not filtering user input Storing Sensitive Data Unencrypted Ignoring bound-checking Not keeping the libraries updated Giving full privileges of the database to a single user Improving your application's security Summary Questions Further reading Chapter 11: Taking the Microservices Approach Technical requirements The shift toward microservices Monolithic development model versus microservices Advantages of the microservices architecture Guidelines for microservice development Service-level agreements in microservices Building your first microservices application The user microservice The to-do manager service Service discovery in microservices Service registry inside microservices Client-side service discovery Server-side service discovery API gateways in microservices Asynchronous communication in microservices Message queues for microservices communication Summary Questions Further reading Chapter 12: Testing and Tracing in Microservices Technical requirements Testing in the microservices world Unit testing in microservices Functionality testing in microservices Integration testing in microservices End-to-end testing in microservices Scalability testing Challenges in microservices testing Tracing requests inside microservices The OpenTracing standard Implementing tracing inside ToDo manager Distributed tracing Benefits of distributed tracing Summary Questions Chapter 13: Going Serverless Technical requirements The serverless approach to application development Components of serverless architecture Backend as a service Function as a service The restrictions on state management Restrictions on execution times Executing functions inside FaaS API gateways in the serverless architecture Understanding the execution of a serverless application Cold-starting a function Hot-starting a function Building our first serverless application A quick introduction to Apache OpenWhisk Setting up the development environment Building our configuration file Integrating with the GitHub API Getting the code ready to run with OpenWhisk Taking the final steps toward deployment Deploying to OpenWhisk Understanding the execution of application Inside Openwhisk Advantages of going serverless Summary Questions Further reading Chapter 14: Deploying to the Cloud Technical requirements Deploying enterprise applications Making a choice about the deployment strategy The different deployment strategies Recreated deployments Rolling deployments Blue/green deployments Canary deployments A/B deployments Shadow deployments Making a choice of infrastructure The traditional infrastructure Containerized approach toward application packaging The move toward the cloud The different types of cloud deployments Private clouds Public clouds Hybrid clouds Summary Questions Chapter 15: Enterprise Application Integration and its Patterns Technical requirements The need for EAI Point-to-point integration Moving towards EAI The traditional approach to EAI The introduction of the ESB Patterns in EAI Integration patterns Mediation pattern Federation pattern Access patterns Asynchronous access patterns Synchronous access patterns Issues in EAI Summary Questions Chapter 16: Microservices and Enterprise Application Integration Technical requirements Microservices and the changing EAI landscape Challenges of traditional EAI in microservices Point-to-point integration of microservices Integrating microservices using the ESB Utilizing API gateways for the integration of microservices Transformation of the ESB Rethinking EAI in microservices Summary Questions Assessment Other Books You May Enjoy Leave a review – let other readers know what you think Index

Similar books