0% found this document useful (0 votes)
23 views30 pages

1 - Service Orientation

Uploaded by

conapoh603
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views30 pages

1 - Service Orientation

Uploaded by

conapoh603
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Service Oriented Architecture

1. Service Orientation

Service Problems Service Architecture Meet Your Tools


Service Oriented Architecture
Airbnb Engineering: http://nerds.airbnb.com/smartstack-service-discovery-cloud/

Companies like Airbnb often start out as monolithic applications — a kind of swiss army knife which Travis-CI
Linux Integrated Testing Continuous
performs all of the functions of the organization. As traffic (and the number of engineers working on the Unix Environment Integration
product) grows, this approach doesn’t scale. The code base becomes too complicated, concerns are not Codeship
cleanly separated, changes from many engineers touching many different parts of the codebase go out Adaptable, scalable services Test behavior, simulate user experience Open Source RubyGems Integrated Deployment Continuous
together, and performance is determined by the worst-performing sections in the application. Service design patterns Behavior Driven Development Development Package Management
Deployment
Continuous Integration, Deployment Continuous Integration, Deployment Heroku
Automated Acceptance tests Automated Acceptance tests Ruby
Monolith Architecture Technical Difficulties: Modern Programming
Cloud Deployment

Large, single, block of stone Hard to add new features Code for humans, not machines Respond to needs, react to changes Sqlite
Cannot change tools/languages Open Source Development Responsive user interfaces GitHub Local SQL Database
Cannot scale beyond ~5000 users Collaborative Development Message Queues Collaborative Development
Conventions, Patterns, Frameworks Asynchronous Jobs PostGres Distributed
Collaborative Git Hosted SQL Database Data Storage
Development Version Control
Human problems: Redis
Developers are constantly “firefighting” CDN Web Sockets Slack Key-value Datastore
Hard to onboard new employees Parallel Group Communication
Worker
queue
Developers skills are out of date HTTP SQS
JS client
ActiveRecord Message Queues
Message
Web External Programming Object-Relational Mapping
SNS Queues
HTTP HTTP HTTP
Web API
Business Problems: Application Web API Frameworks
Hard to change business rules
gem
Sinatra Notification Service
Scheduled Microservice Framework
queue Worker
Cannot innovate
Costs lots of money to maintain Minitest IronWorker Asynchronous
PostGres Testing Framework Background Tasks
Jobs

1
⼤家好!
I am: Soumya Ray
Distinguished Professor
Institute of Service Science
College of Technology Management
[email protected]
https://www.facebook.com/soumya.ray.prof

.com
I’m also: /
soumyaray
@ @gmail.com

2
Communicate: Canvas and Teams

Canvas: courseware
- handouts
- assignments
- readings

Teams: groupware
- weekly discussions
- private team channels
- weekly livestream

3
Canvas
See guide on how to apply/activate your Office 365 account
Link to our MS Teams space to discuss/watch livestream

Complete assignments on week's module

4
MS Teams
We will use MS Teams for all discussion and livestreams

Ask questions about class here.

See weekly channels


for discussions
and livestream.

Post any fun or interesting news or events here.


Ask/share new issues as
new conversations

Log into MS Team using your NTHU Office365 account


- see PDF on Canvas on how to apply/activate your 365 account

5
To do all this, we will make extensive use Amazon’s AWS and other cloud services. The tools and methods
used in this class closely mirror those favored by cutting-edge startups and the open-source movement.
After this class, you will be fully prepared to be an IT entrepreneur and open-source contributor.

Who should take this class?


Everybody Codes
This class is for students who love programming and have a strong background in programming. That means
Syllabus available online
students must already be proficient with the following skills before joining the class:
- Any object-oriented programming language (Java, C#, C++, Python, PHP, Ruby, etc.)
- Web page design (HTML, CSS)
- Database management (Relational databases, SQL)

This class is ideal for students who wish to pursue careers in the following areas.
- Software engineering: discover advanced software design and development tools You should
used be able to
by professionals
- IT project management: manage a sophisticated system with versioning and distributed
write ancoding
application
- Data science: extract and transform data from web sources and store it in cloud-basedbydatastores
yourself.
What will we read?
The Internet is our textbook. Every week, you will be given current online resources that software
developers regularly use to solve problems and expand their knowledge (tutorials, blogs, articls, Q&A
forums, code repositories). We will communicate and collaborate with each other entirely through modern
teamware such as Github and Slack.
You are graded
How will we be graded? solely on your
Students will be graded on class and online discussion, individual assignments, and group
ownassignments.
effort
- Individual Development Effort: 70% (from your recorded activity on code repositories, tutorials, etc.)
- Class and Online Discussion: 30% (you must communicate to get a good grade)

6
Must Know How to Make an Application
12
10
8
6
4
2
0

Data Science Front−end Terminal Back−end Mobile Database−driven IoT Desktop Firmware Server

"Web"
7
Techniques
15
10
5
0

Git VCS OOP basics Command line Database Design HTML/CSS Regex Cloud Deploy Containerization UML Testing OOP advanced

Prequisite Knowledge Major Focus of our Class

8
We are the Service Providers

Airbnb is an example of successful online service:

Grew fast, scaled well.


Very useful, easy-to-use system.
Rated as one of the best places to work.

Have you worked on an IT project


that was fun to develop?
that was difficult to maintain?

9
Why do Software Projects Fail?
https://www.computerworld.com/article/2486426/healthcare-it/healthcare-gov-website--didn-t-have-a-chance-in-hell-
.html

https://www.theguardian.com/society/2013/sep/18/nhs-records-system-10bn

https://www.computerweekly.com/news/2240185166/Universal-Credit-will-cost-taxpayers-128bn

10
Why do Software Projects Fail?
Healthcare.gov website 'didn't have a chance in hell
https://www.computerworld.com/article/2486426/healthcare-it/healthcare-gov-website--didn-t-have-a-chance-in-hell-.html

Of 3,555 projects from 2003 to 2012 that had labor costs of at least $10 million, only 6.4% were successful.

The Standish data showed that 52% of the large projects were "challenged," meaning they were over
budget, behind schedule or didn't meet user expectations.

The remaining 41.4% were failures -- they were either abandoned or started anew from scratch.

Software development experts and analysts point to multiple issues as the potential cause of such problems.

What goes Wrong?


1. "The 'most dangerous' of all failure points for a software
development project is the 'big bang' release"

2. "Other sources of problems, […] could be too many changes


made along the way"
Can these be a problem for
startups or established services
3. "Developing specifications correctly for such a complex design as well?
is a common problem"

4. "Another is sourcing […] multiple parties have worked on


Healthcare.gov, which makes it more difficult to manage"
11
What Happened to Skype?
Microsoft had one big problem to solve early on, though. The
company had acquired a service that was based on peer-to-peer
(P2P) technology, which made it less efficient on mobile devices.
This is where a lot of Microsoft’s Skype problems began.

The transition lasted years, and resulted in calls, messages, and


notifications repeating on multiple devices. Skype became
unreliable, at a time when rivals were continuing to offer solid
alternatives that incorporated messaging functionality that
actually worked and synced across devices. Instead of quickly
fixing the underlying issues, Microsoft spent years trying to
redesign Skype. This led to a lethal combination of an unreliable
product with a user experience that changed on a monthly basis.

https://www.bloomberg.com/opinion/articles/2021-06-04/how-micro

It’s never easy to pinpoint why a product falls out of


fashion, but it often comes down to price, quality,
performance and ease of use.

Microsoft illustrates how having a head start doesn’t matter


if you can’t maintain the lead.

And by 2015, it had 300 million users. But Skype’s technology


wasn’t well-suited to mobile devices. When Microsoft set about
to address that problem, it introduced a host of reliability
nightmares for users. It gave them further headaches by
redesigning Skype frequently and haphazardly while integrating
messaging and video functions.

12
https://www.theverge.com/2020/3/31/21200844/microsoft-skype-zoom-
houseparty-coronavirus-pandemic-usage-growth-competition
Change is a Challenge

Success…

new service startup successful service enterprise

brings change…

basic features ever changing needs

and more people…


simple teams large organization

complicating systems.

small, clean architecture large spaghetti architecture


13
Change is the Enemy of IT Systems!

Change Happens! Fire-Fighting Time Taken

Customers/Managers want new features Quickly Add More Code all the time
design and policies keeps changing old features break; starting debugging

Newly deployed feature doesn't work Live Debugging! days


only works on developers machine find out why it doesn’t work on servers

Platform (iOS) Updates Rush to Update Code weeks


unpredictable changes finding/replacing old code with new code creates new bugs

Programmer Leaves! Rewrite Everything! months


only person who knows API code leaves write entire back-end from scratch

Losing time to innovate!


Competitors moving ahead!
14
Innovation Slows Down

More time between features


(innovation slows down)

v1.3
v1.2
Features

v1.1

Updates becoming smaller


v1.0 (innovation less impressive)

First big design


(seems very innovative!)

Time

What can we do in the beginning to ensure our What should we do later if we find that
system can keep innovating later? our system is too hard to change?

15
How can Architecture Help?
Which system would you rather have to fix?

or

Spaghetti (意⼤利⾯) Layered Service Oriented


Architecture Architecture Architecture

HTTP: Status HTTP: Body (Json)

Representers

Values

Controllers

Service Objects

Entities + Values

Repositories + DataMappers

Object-Relational
Gateways
Mappers

Local Libraries &


External Student

Database Utilities joinDate : Date

API
year : int
track : String


String getTrack()
changeTrack(String)

Components/Objects Outside Service Database Legacy Systems

16
Airbnb Engineering: http://nerds.airbnb.com/smartstack-service-discovery-cloud/

Companies like Airbnb often start out as monolithic applications — a kind of swiss army knife which
performs all of the functions of the organization. As traffic (and the number of engineers working on
the product) grows, this approach doesn’t scale. The code base becomes too complicated, concerns are
not cleanly separated, changes from many engineers touching many different parts of the codebase go
out together, and performance is determined by the worst-performing sections in the application.

Monolith Architecture Technical Complexity:


Large, single, block of stone Too complicated to change features
Cannot change tools/languages (e.g., PHP -> C#)
Cannot scale beyond ~5000 users

Human problems:
Developers are constantly “firefighting” bugs
Hard to onboard new employees
Developers skills are out of date

Business Problems:
Hard to change business rules to market needs
Cannot innovate
Costs lots of money to maintain
17
Airbnb Engineering: http://nerds.airbnb.com/smartstack-service-discovery-cloud/
The solution to this problem is services: individual, smaller code bases, running on separate machines
with separate deployment cycles, that more cleanly address more targeted problem domains.
This is called a services-oriented architecture: SOA.

Service Oriented Architecture


Agility and Flexibility
Add feature easily
Replace services easily

Resilient and Performant


Modify services easily
Scale services selectively

Happy people
Focus and learn what you need
Choose your own tools

More Friends, More Money


Student
Integrate with partners
joinDate : Date

Sell services to others


year : int
track : String


String getTrack()
changeTrack(String)

Components/Objects Outside Service Database Legacy Systems

18
Our SOA Approach
There are many ways of doing SOA -- we will explore a a best of breed approach

HTML / Json

Controllers
Representers
Code for humans, not machines
Services
Domain Driven Design
Domain: Entities + Values

Repositories + DataMappers
Conventions, Patterns, Frameworks "readable"
Coding Metrics
ORM Gateways

Database
External …
API

Test Your Confidence


Test Driven Development "repeatable"
Continuous Integration, Deployment
Can identify violations in agreed flow and usage
Quick and Inexpensive (fits TDD and agile cycle) Automated Acceptance tests

Collaboration and Community


Open Source Development
Collaborative Workflow
"shareable"
Community and Gurus

CDN Web Sockets

Parallel
Worker queue
Extensible, Scalable Services
"scalable"
HTTP

JS client
HTTP Web
Application
HTTP
Web API
gem
HTTP External
Web API
Service Architecture
queue Scheduled
Worker
Message Queues
PostGres
Concurrent Workers

19
Code for Humans, Not Machines
Conventions and Patterns Domain Driven Design
Get feedback on your coding style using automated tools Structure your code into single responsibilities

HTML / Json

Representers
$ gem install rubocop

Avoid use of nested conditionals for flow of control.

Prefer a guard clause when you can assert invalid


Controllers
data. A guard clause is a conditional statement at the
top of a function that bails out as soon as it can.

Services

Domain: Entities + Values

Repositories + DataMappers
Quality Metrics
Quantitatively measure the complexity of your code ORM Gateways
Code metrics: quantifying code quality using crowd-sourced wisdom
ABC Metric: Flog Metric:
External …
ABC is an example of code size metric Specific to Ruby: aware of bad Ruby habits Database API
Counts number of assignments, branches, conditions Extends ABC to weight method calls
Assignment: explicit transfer of data into a variable “The more painful the code, the higher the score.
(= *= /= %= += << , etc.) The higher the score, the harder it is to test.”
Branch: explicit program branch Flog score Means
(method call, new object) 0-10 Awesome
Condition: logical/boolean test 11-20 Good enough
(if-else logic, == != <= >= < > else case , etc.) 21-40 Might need refactoring
41-60 Possible to justify
61-100 Danger
High ABC is bad: code is hard to understand and test
100-200 Whoop, whoop, whoop
Generic metric: ABC applies to any programming language 200+ Someone please think of the children

AbcSize Cop: already included in Rubocop! $ gem install flog


But ABC isn’t aware of Ruby specific code abuses!

20
Test Your Confidence
Test Driven Development Automated Acceptance tests
Use automated tests to guide your coding Simulate and test user experience

Can identify violations in agreed flow and usage


Quick and Inexpensive (fits TDD and agile cycle)

Continuous Integration and Deployment


Automatically test and deploy code regularly
Continuous Deployment
Continuous Delivery Keeping your application
Continuous Integration Keeping the codebase
deployable at any point in time.
deployable at any point. Automatically deploy to
Integrating changes from all developers.
production environment if all
Make sure application passes
Run automated tests during each integration. tests pass
automated tests.
Integration should happen several times a day. Keep configuration information
needed to push into production.

Integrate all Deliver to Application Deploy to Post-Deployment


Code Local Tests
code remotely Staging Acceptance Tests Production Tests

We must be confident all our code will really work. We must be confident our code is
We must publish all tested changes
always ready for end users.
without any delay.
21
Collaboration and Community
Open-Source Development Collaborative Workflow
Use Git/Github to share and collaborate Fork, merge, and pull requests for formal collaboration

Community and Gurus


Watch, listen, and read from the community of developers

Renowned Developers Blogs Local Dev Heroes Developer Conferences


22
Extensible, Scalable Services

Service Architecture Message Queues Concurrent Workers


Compose your system of independent services Use messaging to communicate Multiple processes working independently

CDN Web Sockets

Parallel
Worker queue
HTTP

JS client
HTTP Web HTTP HTTP External
Web API
Application Web API
gem

Scheduled
queue Worker

PostGres

23
Which Road to Take?

Vicious Cycle Virtuous Cycle

Always fighting fires Fix Quickly, Focus on Innovation


Cannot make new things Redeploy code quickly and easily
Afraid to suggest changes Old bugs never resurface

No time to learn new things Always learning


IT services cannot advance IT team always innovates
Losing your own market value Always becoming more hireable!
Feel threatened by new tools Regularly going to conferences and workshops

Get blamed for delays IT team is the heart of innovation


Programmers get sidelined in company Programmers are valued in company
Lose your motivation for coding Programming is more and more enjoyable

Avoid changes? Always changing


Switch careers? Get promoted
Switch companies? Easy to get job offers
Hire more people? Enjoy being part of a team 24
Meet Your Tools

Free: no dependency on proprietary vendors


You will master the tools to build
Open Source: sunlight is the best disinfectant
your first startup, at no cost.
Master Fundamentals: no dependency on IDE or Wizards

25
Our Development Platform

Choose your OS:

or or

Linux Windows Subsystem for Linux MacOS


(WSL) on Windows
Note: Hold off on upgrading to
new MacOS for 1 month.

26
Why are there so many programming languag
How are they different?

27
http://redmonk.com/sogrady/2017/06/08/language-rankings-6-17/
What we Code in Today

"Computer languages differ


not so much in what they make possible,
but in what they make easy.”
15

- Larry Wall (founder of Perl)


10
5
0

python javascript c++ java c# c php ruby swift kotlin r typescript go lua pyspark. sas sass scheme

Programming languages from class survey

28
Growing as a Developer
The safe ALGOL line Ruby: a window to new things
for i := 1 step 1 until 10 do SmallTalk Perl Python
if i MOD 2 :=: 0 then
ALGOL begin print((i, newline))
Object Oriented Flexibility Readability
(1960) end
od

std::stringstream ss;
for (int i = 1; i < 10; i = i + 1) {
Ruby
if (i % 2 == 0) {
C/C++ ss << i << endl;
}
} 10.times { |i| puts i if i.even? }
for (int i = 1; i < 10; i++) {
if (i % 2 == 0) {
Java System.out.println(i); Discover new languages in programming
}
} Return to your favorite language with new eyes

for i in range(1,10):
Python if (i % 2 == 0): print i;

for i := 0; i < 10; i++ {


Golang if i % 2 == 0 { Crystal
fmt.println(i)
} Python Swift R
}
Elixir
Go Kotlin
Java Rust
PHP
Can we express ourselves in better ways? Erlang Scala
29
Linux
Unix Environment Github Actions
Cloud
RubyGems
Continuous Integration
Open Source
Development Production
Package Management
Heroku
Ruby
Cloud Deployment

Modern Programming
Sqlite
Local SQL Database
GitHub
Collaborative Development PostGres Distributed
Hosted SQL Database Data Storage
Collaborative Git
Development Version Control Redis
Key-value Datastore
Trello
Group Communication
SQS Asynchronous
Message Queues Communication
Sequel
Object-Relational Mapping

Programming
Docker
Roda Containers
Frameworks Microservice Framework Containers
DockerHub
Minitest Container Registry
Testing Framework
30

You might also like