Hands-On Software Architecture with Golang

Book description

Understand the principles of software architecture with coverage on SOA, distributed and messaging systems, and database modeling

Key Features

  • Gain knowledge of architectural approaches on SOA and microservices for architectural decisions
  • Explore different architectural patterns for building distributed applications
  • Migrate applications written in Java or Python to the Go language

Book Description

Building software requires careful planning and architectural considerations; Golang was developed with a fresh perspective on building next-generation applications on the cloud with distributed and concurrent computing concerns.

Hands-On Software Architecture with Golang starts with a brief introduction to architectural elements, Go, and a case study to demonstrate architectural principles. You'll then move on to look at code-level aspects such as modularity, class design, and constructs specific to Golang and implementation of design patterns. As you make your way through the chapters, you'll explore the core objectives of architecture such as effectively managing complexity, scalability, and reliability of software systems. You'll also work through creating distributed systems and their communication before moving on to modeling and scaling of data. In the concluding chapters, you'll learn to deploy architectures and plan the migration of applications from other languages.

By the end of this book, you will have gained insight into various design and architectural patterns, which will enable you to create robust, scalable architecture using Golang.

What you will learn

  • Understand architectural paradigms and deep dive into Microservices
  • Design parallelism/concurrency patterns and learn object-oriented design patterns in Go
  • Explore API-driven systems architecture with introduction to REST and GraphQL standards
  • Build event-driven architectures and make your architectures anti-fragile
  • Engineer scalability and learn how to migrate to Go from other languages
  • Get to grips with deployment considerations with CICD pipeline, cloud deployments, and so on
  • Build an end-to-end e-commerce (travel) application backend in Go

Who this book is for

Hands-On Software Architecture with Golang is for software developers, architects, and CTOs looking to use Go in their software architecture to build enterprise-grade applications. Programming knowledge of Golang is assumed.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On Software Architecture with Golang
  3. About Packt
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Building Big with Go
    1. Problem solving for the big picture
      1. The role of the architect
        1. Requirements clarification
        2. True North
        3. Technology selection
        4. Leadership in the kitchen
        5. Coaching and mentoring
        6. Target state versus current state
    2. Software architecture
      1. Architecture versus design
      2. What does architecture look like?
    3. Microservices
      1. The challenges for microservices – efficiency
      2. The challenges for microservices – programming complexity
    4. Go
      1. Hello World!
      2. Data types and structures
      3. Functions and methods
      4. Flow control
      5. Packaging
      6. Concurrency
      7. Garbage collection
      8. Object-orientation
    5. Summary
  7. Packaging Code
    1. Contracts
    2. Object orientation
      1. Object orientation in Go – the struct
      2. Object orientation in Go – visibility
      3. Object oriented in Go – the interface
      4. Object oriented in Go – embedding
    3. Modules
      1. Code layout
      2. Third-party dependencies
      3. Framework
    4. Testing
      1. Structuring tests
    5. Summary
  8. Design Patterns
    1. Design principles
      1. Single Responsibility Principle (S)
      2. Open/Closed Principle (O)
      3. Liskov Substitution Principle (L)
      4. Interface Segregation Principle (I)
      5. Dependency Inversion Principle (D)
    2. Creational design patterns
      1. Factory method
      2. Builder
      3. Abstract factory
      4. Singleton
    3. Structural design patterns
      1. Adaptor
      2. Bridge
      3. Composite
      4. Decorator
      5. Facade
      6. Proxy
    4. Behavioral design patterns
      1. Command
      2. Chain of Responsibility
      3. Mediator
      4. Memento
      5. Observer
      6. Visitor
      7. Strategy
      8. State
    5. Summary
  9. Scaling Applications
    1. Scaling algorithms
      1. Algorithm complexity
      2. Distributed algorithms
    2. Scaling data structures
      1. Profiling data structures
      2. Probabilistic data structures
    3. Scaling data
    4. Scalability bottlenecks
      1. The C10K problem
      2. The Thundering Herd problem
    5. Sources
      1. Programming
      2. Operating systems
      3. Memory usage
    6. Losing state
    7. Scaling systems
      1. X-axis scaling
      2. Y-axis scaling
      3. Z-axis scaling
    8. Scaling deployments
    9. Summary
  10. Going Distributed
    1. Topology
    2. Distributed system quirks
      1. The network is reliable
      2. The latency is zero
      3. The bandwidth is infinite
      4. The network is secure
      5. The topology doesn't change
      6. There is one administrator
      7. The transport cost is zero
      8. The network is homogeneous
    3. Consistency
      1. ACID
      2. Client-centric consistency models
        1. Strong consistency
        2. Weak consistency
        3. Eventual consistency
          1. Sequential consistency
          2. Causal consistency
          3. Session consistency
          4. Monotonic read consistency
          5. Monotonic write consistency
      3. Storage system-centric consistency model
      4. CAP theorem
    4. Consensus
      1. The two generals problem
      2. Consensus based on time – causality
      3. Multi-phase commit
        1. Two-phase commit
        2. Three-phase commit
      4. Paxos
      5. Raft
      6. Leader-election
    5. Distributed architectures
      1. Object-based systems
      2. Layered architectures
      3. Peer-2-peer (P2P) architecture
      4. Distributed computations
      5. Event-driven architecture (EDA)
      6. The Actor model
      7. Stream processing
    6. Summary
  11. Messaging
    1. Performance characterization
    2. Broker-based messaging
      1. The queuing model
      2. The Pub/Sub model
      3. Delivery semantics
        1. Acknowledgement
          1. At-least-once delivery
          2. At-most-once delivery
          3. Exactly-once delivery
      4. Resilience
      5. AMQP
    3. Apache Kafka deep dive
      1. Concepts
      2. Publishing messages
        1. The AsyncProducer interface
        2. The Sync producer
      3. Consuming messages
      4. Stream processing
    4. Brokerless messaging
    5. NSQ deep-dive
      1. Concepts
      2. Publishing messages
      3. Consuming messages
    6. Integration patterns
      1. The request-reply pattern
      2. The correlation identifier pattern
      3. The pipes and filters pattern
      4. The content-based router pattern
      5. The fan-in pattern
      6. The fan-out pattern
      7. The background worker pattern
    7. Summary
  12. Building APIs
    1. Endpoints
      1. Networking basics
      2. Service discovery
        1. Server-side service discovery
        2. Client-side service discovery
    2. Data serialization
      1. XML
      2. JSON
      3. Protobuf
      4. Performance
    3. Representational State Transfer (REST)
      1. Concepts
      2. Constraints
        1. Client-server model
        2. Stateless
        3. Cacheability
        4. Uniform interface
      3. Richardson Maturity Model
        1. Level 0 – swamp of POX
        2. Level 1 – resources
        3. Level 2 – HTTP verbs
        4. Level 3 – hypermedia controls
    4. Building a REST service using Gin
      1. Gin introduction
      2. Sample application
      3. Router
      4. Create
      5. Read
      6. Update
      7. Delete
    5. GraphQL
      1. Schema
      2. Endpoints
        1. Queries
        2. Mutations
        3. Subscriptions
    6. Higher-level patterns
      1. Model-View-Controller (MVC)
      2. Load balancing health checks
      3. API gateway
    7. Go kit
    8. Summary
  13. Modeling Data
    1. Entities and relationships
    2. Consistency guarantees
      1. ACID (Atomicity, Consistency, Isolation, Durability)
        1. Atomicity
        2. Consistency
        3. Isolation
        4. Durability
      2. BASE (Basically Available, Soft state, Eventual consistency)
    3. Relational model
      1. The first normal form
      2. The second normal form
      3. The third normal form
      4. The Boyce-Codd normal form
      5. The fourth normal form
      6. SQL
      7. Indices
      8. Views
        1. Inner join
        2. Left outer join
        3. Right outer join
        4. Full outer join
      9. MySQL deep-dive
        1. Connection management
        2. Query execution
        3. Storage engines
          1. InnoDB
          2. MyISAM
          3. Other plugins
        4. High availability/scalability
      10. Object Relational Mappers (ORMs)
    4. Key/value stores
      1. Concepts
      2. Redis deep-dive
        1. Architecture
        2. Data structures
        3. Persistence
        4. Clustering
        5. Use cases
        6. Golang usage
    5. Wide column stores
    6. Column family stores
      1. Cassandra deep-dive
        1. Data distribution
        2. Write paths
        3. Read paths
        4. Golang usage
    7. Patterns for scaling data performance
      1. Sharding
      2. Denormalization
      3. Materialized views
    8. Summary
  14. Anti-Fragile Systems
    1. Reliability metrics
      1. Dynamic metrics
      2. Static metrics
    2. Engineering reliability
      1. Rugged services
      2. High availability
      3. Messaging
        1. The asynchronous computation pattern
        2. The orchestrator pattern
        3. The compensating-transaction pattern
        4. The pipes and filter pattern
        5. Hotspots
      4. The sidecar pattern
      5. Throttling
      6. Versioning
    3. Reliability verification
      1. Unit tests
      2. Integration tests
      3. UI tests
      4. Performance tests
    4. Chaos-engineering
    5. Dependencies
      1. Failure multiplication
      2. Cascading failures
      3. Dependency resilience
        1. An introduction to Hystrix
        2. Hystrix – fallback
        3. Hystrix – circuit breaker
        4. Hystrix in Golang
        5. Hystrix monitoring
    6. Database-level reliability
    7. Datacenter-level reliability
      1. Consistency
      2. Routing and cutover
    8. Summary
  15. Case Study – Travel Website
    1. The product
      1. Actors
      2. Requirements
    2. Data modeling
    3. High-level architecture
    4. Search
      1. Flights
      2. Hotels
    5. Booking
      1. Payment
      2. Reservation
    6. Summary
  16. Planning for Deployment
    1. Deployment architecture
      1. Components
        1. Computes
          1. Physical Servers
          2. Virtual machines
          3. Containers
          4. Compute Attributes
        2. Storage
        3. Networking
        4. Load Balancers
        5. API Gateways
        6. Reverse proxies
        7. Messaging brokers
      2. Environments
      3. Capacity Planning and Sizing
      4. Disaster recovery
    2. CICD
      1. Overview
      2. Jenkins
        1. Sample Code
        2. Installing Jenkins
        3. Installing Docker
        4. Setting up Plugins
        5. Creating a project
        6. Running the Build
      3. Target Configuration
      4. Tooling
        1. go fmt
        2. golint
        3. go build
      5. Footnote
    3. Monitoring
      1. Logs
      2. Metrics
      3. Application Performance Monitoring/Dashboards
      4. Alerts
      5. Team
    4. Clouds
      1. Infrastructure as a Service (IaaS)
      2. Platform as a Service (PaaS)
      3. Software as a service (SaaS)
    5. Security
    6. Summary
  17. Migrating Applications
    1. Reasons for migration
      1. Python
      2. Java
    2. Migration strategy
      1. Phase 1 – Learning Go
      2. Phase 2 – Piloting a service
      3. Phase 3 – Defining packages
      4. Phase 4 – Porting main
      5. Phase 5 – Porting packages
      6. Phase 6 – Improving computation
    3. Building a team
    4. Summary
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Hands-On Software Architecture with Golang
  • Author(s): Jyotiswarup Raiturkar
  • Release date: December 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788622592