logo资料库

Hands-On Software Architecture with Golang.pdf

第1页 / 共491页
第2页 / 共491页
第3页 / 共491页
第4页 / 共491页
第5页 / 共491页
第6页 / 共491页
第7页 / 共491页
第8页 / 共491页
资料共491页,剩余部分请下载后查看
Cover
Title Page
Copyright and Credits
About Packt
Contributors
Table of Contents
Preface
Chapter 1: Building Big with Go
Problem solving for the big picture
The role of the architect
Requirements clarification
True North
Technology selection
Leadership in the kitchen
Coaching and mentoring
Target state versus current state
Software architecture
Architecture versus design
What does architecture look like?
Microservices
The challenges for microservices – efficiency
The challenges for microservices – programming complexity
Go
Hello World!
Data types and structures
Functions and methods
Flow control
Packaging
Concurrency
Garbage collection
Object-orientation
Summary
Chapter 2: Packaging Code
Contracts
Object orientation
Object orientation in Go – the struct
Object orientation in Go – visibility
Object oriented in Go – the interface
Object oriented in Go – embedding
Modules
Code layout
Third-party dependencies
Framework
Testing
Structuring tests
Summary
Chapter 3: Design Patterns
Design principles
Single Responsibility Principle (S)
Open/Closed Principle (O)
Liskov Substitution Principle (L)
Interface Segregation Principle (I)
Dependency Inversion Principle (D)
Creational design patterns
Factory method
Builder
Abstract factory
Singleton
 Structural design patterns
Adaptor
Bridge
Composite
Decorator
Facade
Proxy
Behavioral design patterns
Command
Chain of Responsibility
Mediator
Memento
Observer
Visitor
Strategy
State
Summary
Chapter 4: Scaling Applications
Scaling algorithms
Algorithm complexity
Distributed algorithms
Scaling data structures
Profiling data structures
Probabilistic data structures
Scaling data
Scalability bottlenecks
The C10K problem
The Thundering Herd problem
Sources
Programming
Operating systems
Memory usage
Losing state
Scaling systems
X-axis scaling
Y-axis scaling
Z-axis scaling
Scaling deployments
Summary
Chapter 5: Going Distributed
Topology
Distributed system quirks
The network is reliable
The latency is zero
The bandwidth is infinite
The network is secure
The topology doesn't change
There is one administrator
The transport cost is zero
The network is homogeneous
Consistency
ACID
Client-centric consistency models
Strong consistency
Weak consistency
Eventual consistency
Sequential consistency
Causal consistency
Session consistency
Monotonic read consistency
Monotonic write consistency
Storage system-centric consistency model
CAP theorem
Consensus
The two generals problem
Consensus based on time – causality
Multi-phase commit
Two-phase commit
Three-phase commit
Paxos
Raft
Leader-election
Distributed architectures
Object-based systems
Layered architectures
Peer-2-peer (P2P) architecture
Distributed computations
Event-driven architecture (EDA)
The Actor model
Stream processing
Summary
Chapter 6: Messaging
Performance characterization
Broker-based messaging
The queuing model
The Pub/Sub model
Delivery semantics
Acknowledgement
At-least-once delivery
At-most-once delivery
Exactly-once delivery
Resilience
AMQP
Apache Kafka deep dive
Concepts
Publishing messages
The AsyncProducer interface
The Sync producer
Consuming messages
Stream processing
Brokerless messaging
NSQ deep-dive
Concepts
Publishing messages
Consuming messages
Integration patterns
The request-reply pattern
The correlation identifier pattern
The pipes and filters pattern
The content-based router pattern
The fan-in pattern
The fan-out pattern
The background worker pattern
Summary
Chapter 7: Building APIs
Endpoints
Networking basics
Service discovery
Server-side service discovery
Client-side service discovery
Data serialization
XML
JSON
Protobuf
Performance
Representational State Transfer (REST)
Concepts
Constraints
Client-server model
Stateless
Cacheability
Uniform interface
Richardson Maturity Model
Level 0 – swamp of POX
Level 1 – resources
Level 2 – HTTP verbs
Level 3 – hypermedia controls
Building a REST service using Gin
Gin introduction
Sample application
Router
Create
Read
Update
Delete
GraphQL
Schema
Endpoints
Queries
Mutations
Subscriptions
Higher-level patterns
Model-View-Controller (MVC)
Load balancing health checks
API gateway
Go kit 
Summary
Chapter 8: Modeling Data
Entities and relationships
Consistency guarantees
ACID (Atomicity, Consistency, Isolation, Durability)
Atomicity
Consistency
Isolation
Durability
BASE (Basically Available, Soft state, Eventual consistency)
Relational model
The first normal form
The second normal form
The third normal form
The Boyce-Codd normal form
The fourth normal form
SQL
Indices
Views
Inner join
Left outer join
Right outer join
Full outer join
MySQL deep-dive
Connection management
Query execution
Storage engines
InnoDB
MyISAM
Other plugins
High availability/scalability
Object Relational Mappers (ORMs)
Key/value stores
Concepts
Redis deep-dive
Architecture
Data structures
Persistence
Clustering
Use cases
Golang usage
Wide column stores
Column family stores
Cassandra deep-dive
Data distribution
Write paths
Read paths
Golang usage
Patterns for scaling data performance
Sharding
Denormalization
Materialized views
Summary
Chapter 9: Anti-Fragile Systems
Reliability metrics
Dynamic metrics
Static metrics
Engineering reliability
Rugged services
High availability
Messaging
The asynchronous computation pattern
The orchestrator pattern
The compensating-transaction pattern
The pipes and filter pattern
Hotspots
The sidecar pattern
Throttling
Versioning 
Reliability verification
Unit tests
Integration tests
UI tests
Performance tests
Chaos-engineering
Dependencies
Failure multiplication
Cascading failures
Dependency resilience
An introduction to Hystrix
Hystrix – fallback
Hystrix – circuit breaker
Hystrix in Golang
Hystrix monitoring
Database-level reliability
Datacenter-level reliability
Consistency
Routing and cutover
Summary
Chapter 10: Case Study – Travel Website
The product
Actors
Requirements
Data modeling
High-level architecture
Search
Flights
Hotels
Booking
Payment
Reservation
Summary
Chapter 11: Planning for Deployment
Deployment architecture
Components
Computes
Physical Servers
Virtual machines
Containers
Compute Attributes
Storage
Networking
Load Balancers
API Gateways
Reverse proxies
Messaging brokers
Environments
Capacity Planning and Sizing
Disaster recovery
CICD
Overview
Jenkins
Sample Code
Installing Jenkins
Installing Docker
Setting up Plugins
Creating a project
Running the Build
Target Configuration
Tooling
go fmt
golint
go build
Footnote
Monitoring
Logs
Metrics
Application Performance Monitoring/Dashboards
Alerts
Team
Clouds
Infrastructure as a Service (IaaS)
Platform as a Service (PaaS)
Software as a service (SaaS)
Security
Summary
Chapter 12: Migrating Applications
Reasons for migration
Python
Java
Migration strategy
Phase 1 – Learning Go
Phase 2 – Piloting a service
Phase 3 – Defining packages
Phase 4 – Porting main
Phase 5 – Porting packages
Phase 6 – Improving computation
Building a team
Summary
Other Books You May Enjoy
Index
Hands-On Software Architecture with Golang Design and architect highly scalable and robust applications using Go Jyotiswarup Raiturkar BIRMINGHAM - MUMBAI
Hands-On Software Architecture with Golang Copyright © 2018 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Merint Mathew Acquisition Editor: Chaitanya Nair Content Development Editor: Rohit Kumar Singh Technical Editor: Ketan Kamble Copy Editor: Safis Editing Project Coordinator: Vaidehi Sawant Proofreader: Safis Editing Indexer: Tejal Daruwale Soni Graphics: Alishon Mendonsa Production Coordinator: Arvindkumar Gupta First published: December 2018 Production reference: 1071218 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78862-259-2 www.packtpub.com
mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. Why subscribe? Spend less time learning and more time coding with practical ebooks and videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free ebook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content Packt.com Did you know that Packt offers ebook versions of every book published, with PDF and ePub files available? You can upgrade to the ebook version at www.packt.com and as a print book customer, you are entitled to a discount on the ebook copy. Get in touch with us at customercare@packtpub.com for more details. At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and ebooks.
Contributors About the author Jyotiswarup Raiturkar has architected products ranging from high-volume e-commerce sites to core infrastructure products. Notable products include the Walmart Labs Ecommerce Fulfillment Platform, Intuit Mint, SellerApp, Goibibo, Microsoft Virtual Server, and ShiftPixy, to name a few. Nowadays, he codes in Golang, Python, and Java.
About the reviewer Peter Malina is a CTO at a Brno-based software agency called FlowUp. He is a cloud lover, a bleeding-edge technology pioneer, and a Golang and Angular specialist. He also is a speaker at local events and is an enthusiastic Kubernetes and GCP solution architect. Packt is searching for authors like you If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Table of Contents Preface Chapter 1: Building Big with Go Problem solving for the big picture The role of the architect Requirements clarification True North Technology selection Leadership in the kitchen Coaching and mentoring Target state versus current state Software architecture Architecture versus design What does architecture look like? Microservices Go Hello World! Data types and structures Functions and methods Flow control Packaging Concurrency Garbage collection Object-orientation Summary Chapter 2: Packaging Code Contracts Object orientation The challenges for microservices – efficiency The challenges for microservices – programming complexity Object orientation in Go – the struct Object orientation in Go – visibility Object oriented in Go – the interface Object oriented in Go – embedding Modules Code layout Third-party dependencies Framework Testing Structuring tests 1 7 8 9 10 10 11 11 11 12 12 12 13 17 21 22 23 26 26 28 30 31 33 35 36 37 38 39 40 47 49 50 54 57 57 59 62 62 63
Table of Contents Summary Chapter 3: Design Patterns Design principles Single Responsibility Principle (S) Open/Closed Principle (O) Liskov Substitution Principle (L) Interface Segregation Principle (I) Dependency Inversion Principle (D) Creational design patterns Structural design patterns Factory method Builder Abstract factory Singleton Adaptor Bridge Composite Decorator Facade Proxy Behavioral design patterns Command Chain of Responsibility Mediator Memento Observer Visitor Strategy State Summary Chapter 4: Scaling Applications Scaling algorithms Algorithm complexity Distributed algorithms Scaling data structures Profiling data structures Probabilistic data structures Scaling data Scalability bottlenecks The C10K problem The Thundering Herd problem Sources Programming Operating systems [ ii ] 65 66 66 67 68 69 70 71 72 73 73 75 77 78 78 79 82 83 84 85 86 86 89 90 92 93 95 98 100 102 103 105 105 109 111 111 114 115 116 116 118 118 119 120
分享到:
收藏