PHP Microservices: Transit from monolithic architectures to highly available, scalable, and fault-tolerant microservices
Book information
Description
Transit from monolithic architectures to highly available, scalable, and fault-tolerant microservices Key Features Build your own applications based on event-driven microservices and set them up on a production server. Successfully transform any monolithic application into a microservice. Monitor the health of your application, prevent downtime, and reduce costs. Book Description The world is moving away from bulky, unreliable, and high-maintenance PHP applications, to small, easy-to-maintain and highly available microservices and the pressing need is for PHP developers to understand the criticalities in building effective microservices that scale at large. This book will be a reliable resource, and one that will help you to develop your skills and teach you techniques for building reliable microservices in PHP. The book begins with an introduction to the world of microservices, and quickly shows you how to set up a development environment and build a basic platform using Docker and Vagrant. You will then get into the different design aspects to be considered while building microservices in your favorite framework and you will explore topics such as testing, securing, and deploying microservices. You will also understand how to migrate a monolithic application to the microservice architecture while keeping scalability and best practices in mind. Furthermore you will get into a few important DevOps techniques that will help you progress on to more complex domains such as native cloud development, as well as some interesting design patterns. By the end of this book you will be able to develop applications based on microservices in an organized and efficient way. You will also gain the knowledge to transform any monolithic applications into microservices. What you will learn Set up a development environment using the right strategies and tools. Learn about application design and structure to start implementing your application. Transform a monolithic application into microservices. Explore the best way to start implementing your application using testing. Understand how to monitor your microservices, handle errors, and debug the application. Deploy your finished application into a production environment and learn how to solve common problems. Know how to scale your application based on microservices once it is up–and-running. Cover ......Page 1 Copyright......Page 3 Credits......Page 4 About the Authors......Page 5 About the Reviewer......Page 6 www.PacktPub.com......Page 7 Customer Feedback......Page 8 Table of Contents......Page 9 Preface......Page 19 Chapter 1: What are Microservices?......Page 24 Monolithic versus microservices......Page 25 Service Oriented Architectures versus microservices......Page 28 Microservices characteristics......Page 29 Successful cases......Page 30 Disadvantages of microservices......Page 31 Always create small logical black boxes......Page 32 Use queues to reduce a service load or make async executions......Page 33 Advantages of using PHP on microservices......Page 34 A short history of PHP......Page 35 Version 6.x......Page 36 Advantages......Page 37 Disadvantages......Page 39 Summary......Page 40 Chapter 2: Development Environment......Page 41 Design and architecture to build the basic platform for microservices......Page 42 Requirements to start working on microservices......Page 43 Installing Docker on macOS......Page 44 Docker for Mac installation process......Page 45 Installing Docker on Linux......Page 46 Installing Docker using yum......Page 47 Installing Docker on Ubuntu......Page 48 Installing Docker using apt......Page 49 Common issues on Ubuntu......Page 50 DNS server......Page 51 Starting Docker on boot......Page 52 Installing the Docker tools......Page 53 Quick example to check your Docker installation......Page 55 Common management tasks......Page 56 Git......Page 57 GitHub......Page 60 Feature branch workflow......Page 61 Forking workflow......Page 62 Setting up a development environment for microservices......Page 63 Autodiscovery service......Page 65 Microservice base core – NGINX and PHP-FPM......Page 66 PHP-FIG......Page 74 PSR-7......Page 75 Headers......Page 76 Request targets and URIs......Page 77 Uploaded files......Page 78 Middleware......Page 79 Phalcon......Page 83 Lumen......Page 84 Silex (based on Symfony)......Page 85 Summary......Page 86 Microservices structure......Page 87 API gateway......Page 89 Service discovery and registry......Page 90 Database per service......Page 91 RESTful conventions......Page 92 Standards......Page 93 Consumer amenities......Page 94 General caching strategy......Page 95 HTTP caching......Page 98 Static files caching......Page 100 How domain-driven design works......Page 101 Using domain-driver design in microservices......Page 104 Event-driven architecture......Page 105 Event-driven architecture in microservices......Page 106 What is continous integration?......Page 109 Tools for continuous integration......Page 110 Continuous delivery ......Page 111 Benefits of continuous delivery......Page 112 Summary......Page 113 The importance of using tests in your application......Page 114 Testing in microservices......Page 115 Test-driven development......Page 116 How to do TDD?......Page 117 Why should I use TDD?......Page 118 Red – writing the unit tests......Page 120 Refactor – eliminate redundancy......Page 121 Cucumber as DSL for BDD......Page 122 Acceptance test-driven development......Page 124 User stories......Page 125 Discuss......Page 126 Demo......Page 127 PHPUnit......Page 128 Unit testing......Page 130 Running the tests......Page 131 assertArrayHasKey......Page 132 assertClassHasAttribute......Page 133 assertClassHasStaticAttribute......Page 134 assertDirectory() and assertFile()......Page 135 assertString()......Page 136 assertJson()......Page 137 Other assertions......Page 138 Unit testing from scratch......Page 139 Test execution......Page 146 Behat example from scratch......Page 147 Selenium......Page 150 Summary......Page 151 Dependency management......Page 152 Routing......Page 154 Postman......Page 157 Middleware......Page 159 Implementing a microservice call......Page 160 Request life cycle......Page 163 Communication between microservices with Guzzle......Page 164 Database operations......Page 167 Validation......Page 176 Manage exceptions......Page 179 Async and queue......Page 182 Caching......Page 185 Summary......Page 189 What is debugging?......Page 190 Debugging installation......Page 191 Debugging setup......Page 193 Debugging the output......Page 194 Profiling installation......Page 195 Analyzing the output file......Page 196 Why is error handling important?......Page 197 Basic die() function......Page 198 Custom error handling......Page 199 Render method......Page 200 Error handling with Sentry......Page 201 Application logs......Page 206 Challenges in microservices......Page 207 Logs in Lumen......Page 208 Application monitoring......Page 209 Application level......Page 210 Datadog......Page 211 Infrastructure level......Page 212 Prometheus......Page 213 Weave Scope......Page 216 Summary......Page 218 Encryption in microservices......Page 219 Database encryption......Page 220 Encryption in MariaDB......Page 221 InnoDB encryption......Page 223 TSL/SSL protocols......Page 224 How the TSL/SSL protocol works......Page 225 TSL/SSL termination......Page 226 TSL/SSL with NGINX......Page 227 Authentication......Page 229 OAuth 2 installation......Page 233 Setup......Page 234 Let's try OAuth2......Page 235 How to use JWT on Lumen......Page 237 Setting up JWT......Page 238 Let's try JWT......Page 242 What is ACL?......Page 243 How to use ACL......Page 244 Environment variables......Page 246 Tracking and monitoring......Page 247 File permissions and ownership......Page 248 Session hijacking......Page 249 Password policies......Page 250 Summary......Page 251 Composer require-dev......Page 252 Vendor folder on repository......Page 253 Grunt......Page 254 SASS......Page 256 Bower......Page 257 Simple PHP script......Page 258 Ansible and Ansistrano......Page 259 Ansible installation......Page 260 How does Ansistrano work?......Page 261 Deploying with Ansistrano......Page 263 Other deployment tools......Page 265 Continuous integration with Jenkins......Page 266 Blue/Green deployment......Page 267 Canary releases......Page 268 Immutable infrastructure......Page 269 Why is it important?......Page 270 Full backup......Page 271 Bacula......Page 272 Percona xtrabackup......Page 273 Be ready for the apocalypse......Page 274 Summary......Page 275 Stop diving......Page 276 Divide frontend and backend......Page 278 How to extract a module......Page 280 Tutorial: From monolithic to microservices......Page 281 Stop diving......Page 282 Divide frontend and backend......Page 288 Extraction services......Page 293 Summary......Page 302 Capacity planning......Page 303 Knowing the limits of your application......Page 304 Availability math......Page 307 Apache JMeter......Page 310 Installing Apache JMeter......Page 311 Executing load tests with Apache JMeter......Page 312 Installing Artillery......Page 320 Executing loading tests with Artillery......Page 321 Creating Artillery scripts......Page 323 Advanced scripting......Page 324 Installing siege on RHEL, CentOS, and similar operating systems......Page 325 Quick siege example......Page 326 Scalability plan......Page 327 Step #1......Page 329 Step #3......Page 330 Summary......Page 331 Code versioning best practices......Page 332 Handle cache misses......Page 333 Choose your cache algorithm carefully......Page 334 Minimize HTTP requests......Page 335 Minimize HTML, CSS, and JavaScript......Page 336 Use lossless image compression......Page 337 Use data URIs......Page 338 Cache, cache, and more cache......Page 339 Dependency management......Page 340 Semantic versioning......Page 341 We have been told that there is a bug in our project......Page 342 Client request successful......Page 343 Client request incomplete......Page 344 Dealing with strings......Page 345 Regular expressions......Page 346 Working with release branches......Page 347 Quick example......Page 348 Summary......Page 349 What is Cloud?......Page 350 Autoscalable and elastic......Page 351 Grow faster......Page 352 Amazon Web Services (AWS)......Page 353 Microsoft Azure......Page 354 DigitalOcean......Page 355 Google Compute Engine......Page 356 Docker Swarm......Page 357 Installing Docker Swarm......Page 358 Adding services to our Swarm......Page 361 Scaling your services in Swarm......Page 364 Kubernetes......Page 365 Deploying to Joyent Triton......Page 367 What is DevOps?......Page 368 Summary......Page 370 Index......Page 371
Similar books
MySQL® Notes for Professionals book
2018 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36
2010 · PDF
THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.
1858 · PDF
Idries Shah 27 Books Collection : A Perfumed Scorpion, A Veiled Gazelle, Caravan of Dreams, Darkest England, Destination Mecca, Evenings with Idries Shah, Knowing How to Know, Learning How to Learn, Letters and Lectures of Idries Shah, Neglected aspects of Sufi study, Observations, Oriental Magic, Reflections, Seeker after Truth, Special Illumination, Special Problems in the study of Sufi ideas, Sufi thought and action, Tales of the Dervishes, The Dermis Probe, The Elephant in the Dark, The Englishman Handbook, Idries Shah Antology, The Magic Monastery, The natives are restless, wisdom of the Idiots PDF.
2022 · PDF
The travels of Capts. Lewis and Clarke from St. Louis, by way of the Missouri and Columbia rivers, to the Pacific ocean; performed in the years 1804, 1805 & 1806, by order of the government of the United States. Containing delineations of the manners, customs, religion, &c. of the Indians, comp. from various authentic sources, and original documents, and a summary of the Statistical view of the Indian nations, from the official communication of Meriwether Lewis. Illustrated with a map of the country, inhabited by the western tribes of Indians
1809 · PDF
Professional Linux kernel architecture ''Wrox programmer to programmer''--Cover. - ''What you are reading right now is the result of an evolution over more than seven years: After two years of writing, the first edition was published in German by Carl Hanser Verlag in 2003. It then described kernel 2.6.0. The test was used as a basis for the low-level design documentation for the EAL4+ security evaluation of Red Hat Enterprise Linux 5, requiring to update it to kernel 2.6.18 (if the EAL acronym does not mean anything to you, then Wikipedia is once more your friend). Hewlett-Packard sponsored the translation into English and has, thankfully, granted the rights to publish the result. Updates to kernel 2.6.24 were then performed specifically for this book''--P. ix
2008 · PDF