Why 12 Factor Application Patterns, Microservices and CloudFoundry Matter (Part 2)
Learn why 12 Factor Application Patterns, Microservices and CloudFoundry matter when trying to change the way your product is produced.
Join the DZone community and get the full member experience.
Join For FreeI first described a difficult scenario that I faced a few years ago. This article is my recommendations to the current custodians of that project on what to change and how.
With the help of open source frameworks like Spring Cloud and open source platforms like Cloudfoundry, you aren’t forced into having a fragile, manual SDLC. The first step is to embrace change and join a vibrant community that is succeeding in software development.
Overview
- Increase agility through process, tools and culture
- Examine the code and depedencies, determine modules based on business domain.
- Refactor the monolithic EAR into microservices living in JARs guided by the 12 Factor Application patterns and microservices recommendations.
- 12FA – III – Store configuration in the environment (or even better use a configuration server)
- Change the Development Process, Frameworks, Libraries and Tools.
- Change the Build Process and Tools. Embrace Gradle, Maven, JDK 8.
- Change the Delivery Process. Enact Continuous delivery.
- Change the Database modifications and migration Process and Tools.
- Change the run-time platform from legacy application server to a PaaS.
- Centralize the logging. Using PCF Loggregator and tools like ELK and PaperTrail.
- Embrace industry standard open source tools, libraries and frameworks
- Good code fails when you don’t have good process and a platform to help you.
- Good teams fail when you don’t have a good culture that embraces DevOps, microservices and not giant monoliths.
So how could we have improved our process? The first step is to admin you have a problem and seek help. By looking to the community, open source and successful startups that have faced similar struggles with monolithic J2EE code bases (Ebay, Netflix), we can determine some functional patterns.
Patterns and Principles for Change
- Use Jenkins to deploy your app with no downtime to CloudFoundry.
- Use CloudFoundry deployments to do A/B testing with no downtime or difficulty.
- Bind to database, using the same process in development, test, Q/A and production. No manual configuration or configuration changes. Operators make available the correct database settings through the marketplace. Same manifest and bindings will point to different databases in different spaces.
- To migrate database changes use flywaydb or liquibase. These are very well integrated into Spring Boot.
- Look at NoSQL for part of your database workload, polyglot persistence makes sense in many cases. For MongoDB development, you handle change management with Mongeez, which is automatically done with JHipster.
- Smoke tests and automated tests tied to Jenkins.
- Test against CloudFoundry development for local development, fast deployments, run unit and integration tests locally.
- Use Maven or Gradle for builds, not ANT.
- Use Circuit breakers in your web calls to avoid breaking systems and fail safely.
- Use APM and JMX for deep checks using Pivotal Ops Metrics for CloudFoundry.
- Have automated scripts check one log stream. Use tools like ELK (ElasticSearch+Logstash+Kibana) to examine logs.
- Use CloudFoundry containers that don’t make you SSH to many machines, removing a big manual step that could be a security issue.
- Move to using smaller, lighterweight Spring Boot Jars and Wars; not giant EAR files.
- Use lightweight web containers like Jetty, Tomcat, tcServer, or Undertow.
- Use lightweight frameworks, remember YAGNI and KISS.
- Read and embrace: Release It!
- Break up the apps into smaller, logical components that model real business functionality.
- Refactor existing code guided by tests, enhancing and adding more tests as the code evolves. Remembering to use code coverage tools like Jacoco.
- Design clean RESTful APIs guided by SRP (Single Responsibility Principle).
- Use smart, modern opinionated frameworks for development like Spring Boot, DropWizard and RatPack.
- Install GVM and use it to install SpringBoot, Gradle, Groovy, LazyBones and other great tools. example: gvm install springboot
- Use Spring Cloud Connectors, Spring Cloud Netflix projects for Service Discovery and other useful services to enable microservices orchestration and development.
- Use a very helpful application generator like JHipster.
- Use Domain Driven Design.
- Keep to the basics of OOD for existing code and Functional Reactive Programming for new code.
- Document your API with Spring REST Docs or Swagger. There is a great presentation on that here.
- Start your green field projects with one button click or use the Spring CLI (spring init -d=web,data-jpa,actuator,data-rest –build=maven newappdir/).
References
- http://www.agilemobiledeveloper.com/2014/12/29/critical-tools/
- http://www.agilemobiledeveloper.com/2015/01/05/tools-for-crushing-high-availability-and-scalability-part-i/
Service Discovery
Published at DZone with permission of Tim Spann, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments