how to build a micro-services infrastructure in 7 days€¦ · micro-services infrastructure in 7...
TRANSCRIPT
![Page 1: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/1.jpg)
How To Build A
Micro-Services Infrastructure
in 7 Days
Gil Tayar, November 2017
@giltayar
![Page 2: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/2.jpg)
Wix Internal
Hackathon -
December 2015
![Page 3: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/3.jpg)
About Me ● My developer experience goes all the way back to the ‘80s.
● Am, was, and always will be a developer● Currently evangelist and architect at
Applitools● Visual Testing
● Sometimes my arms bend back● But the gum I like is coming back in style
![Page 4: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/4.jpg)
A Movie Script in 6 Parts1. Prolog
2. The Plan
3. The Job
4. The Change of Plan
5. It All Comes Together
6. Epilog
![Page 5: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/5.jpg)
1. Prolog
![Page 6: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/6.jpg)
Wix
![Page 7: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/7.jpg)
Statistics
● 100 Million Users
● 2B HTTP Requests/Day
● Over 200 Micro-services
● 100 Deployments/Day
![Page 8: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/8.jpg)
And an Aging Micro-
Services Infra!
![Page 9: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/9.jpg)
What is a Micro-services infrastructure?
Service A
Service B
Service C
Service A
Service B
Service C
Service A
Service C
Service D
Service A
Service C
Service D
Service A
Service B
Service D
Deploying
Running
Keeping Healthy
![Page 10: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/10.jpg)
Is It That Bad?
![Page 11: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/11.jpg)
Slow Deployments…
Chef-based
Suboptimal Blue/Green Deployment
Slow Rollbacks
![Page 12: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/12.jpg)
Static DefinitionsInstance of Service A
Instance of Service B
Instance of Service C
Instance of Service B
Instance of Service C
Instance of Service D
Instance of Service A
Instance of Service C
Instance of Service D
Foo
Bar
Baz
![Page 13: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/13.jpg)
Different Staging Infra
Different E2E Testing Infra
![Page 14: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/14.jpg)
Can we rebuild it?
In a week?
![Page 15: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/15.jpg)
![Page 16: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/16.jpg)
![Page 17: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/17.jpg)
![Page 18: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/18.jpg)
2. The Plan`
![Page 19: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/19.jpg)
December 15, 2015
![Page 20: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/20.jpg)
The Scope
![Page 21: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/21.jpg)
The Scope (I)
sample-web-servicesample-web-serviceweb-service
sample-web-servicesample-web-servicerpc-service
![Page 22: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/22.jpg)
The Scope (II)
$ npm install -g apollo
$ apollo artifact-deploy web-service:1.5.0 -n 20
$ curl web-service.demo-domain.com/....
$ apollo artifact-deploy web-service:1.6.0 -n 30
![Page 23: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/23.jpg)
The Scope (II)
$ npm install -g apollo
$ apollo artifact-deploy web-service:1.5.0 -n 20
$ curl web-service.demo-domain.com/....
$ apollo artifact-deploy web-service:1.6.0 -n 30
![Page 24: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/24.jpg)
The Scope (II)
$ npm install -g apollo
$ apollo artifact-deploy web-service:1.5.0 -n 20
$ curl web-service.demo-domain.com/....
$ apollo artifact-deploy web-service:1.6.0 -n 30
![Page 25: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/25.jpg)
The Scope (II)
$ npm install -g apollo
$ apollo artifact-deploy web-service:1.5.0 -n 20
$ curl web-service.demo-domain.com/....
$ apollo artifact-deploy web-service:1.6.0 -n 30
![Page 26: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/26.jpg)
The Scope (II)
$ npm install -g apollo
$ apollo artifact-deploy web-service:1.5.0 -n 20
$ curl web-service.demo-domain.com/....
$ apollo artifact-deploy web-service:1.6.0 -n 30
![Page 27: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/27.jpg)
And we should have
some marketing!
![Page 28: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/28.jpg)
Apollo: Tomorrow’sInfrastructure Today
Deploy Like a Boss‘Cause it’s Built on Mesos
![Page 29: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/29.jpg)
The Scheduler
![Page 30: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/30.jpg)
This is a Server Farm
![Page 31: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/31.jpg)
These are Micro-Service Instances
A
B
C
D
E
EE
E
E
E
E
E
D D
D
D
D
D
C
C
C
C
C
CB BB
B
B
B
B
BB
B
B
B
B
C
C
C
C
C
C
CC
C
C
A
AA
AA
A
A
A
A
A
A
A
A
E
E
E
EE
D
D
D
D
![Page 32: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/32.jpg)
We Need To Put These Into These
A
B
C
D
E
EE
E
E
E
E
E
D D
D
D
D
D
C
C
C
C
C
CB BB
B
B
B
B
BB
B
B
B
B
C
C
C
C
C
C
CC
C
C
A
AA
AA
A
A
A
A
A
A
A
A
E
E
E
EE
D
D
D
D
![Page 33: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/33.jpg)
And This is What a Scheduler Does
C
D E
E
E
C
B
B
B
E
C
C
C A
A
D
C
C
A
A
A
E
C
B
A
A
E
ED
D
C
BB
B
E
E
A
E
D C
C
B
B
B
B
C
A
D
B
DB
C
C
A
A A
D
E
D BC
C C
A A
E
E
D D
I need 20 A’s,
10 B’s, 15 C’s...
![Page 34: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/34.jpg)
Which Scheduler?
Mesos/Marathon
Mesos/Aurora
Kubernetes
Nomad
![Page 35: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/35.jpg)
This Scheduler!
Mesos/Marathon
![Page 36: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/36.jpg)
Why?
Mesos/Marathon
![Page 37: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/37.jpg)
Because!
Why?
Mesos/Marathon
![Page 38: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/38.jpg)
Service Discovery
![Page 39: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/39.jpg)
Three Kinds
sample-web-servicesample-web-serviceweb-service
sample-web-servicesample-web-servicerpc-servicemysql1
![Page 40: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/40.jpg)
Web Service Discovery
sample-web-servicesample-web-serviceweb-service
sample-web-servicesample-web-servicerpc-servicemysql1
wix.com/w/...
![Page 41: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/41.jpg)
RPC Service Discovery
sample-web-servicesample-web-serviceweb-service
sample-web-servicesample-web-servicerpc-servicemysql1
service.doSomething("a", 4)
![Page 42: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/42.jpg)
3rd Party
Service Discovery
sample-web-servicesample-web-serviceweb-service
sample-web-servicesample-web-servicerpc-servicemysql1
Select * from ...
![Page 43: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/43.jpg)
3rd Party
Service Discovery
sample-web-servicesample-web-serviceweb-service
sample-web-servicesample-web-servicerpc-servicemysql1
Select * from ...
![Page 44: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/44.jpg)
How To Implement
Web Service
Discovery
![Page 45: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/45.jpg)
Web Service Discovery
sample-web-servicesample-web-serviceWeb-service Asample-web-servicesample-web-serviceWeb-service B
Gateway
wix.com/z/...rules
wix.com/w/...
/w ⇒ A/z ⇒ B
![Page 46: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/46.jpg)
Which Proxy?
sample-web-servicesample-web-serviceAsample-web-servicesample-web-serviceB
Gateway
wix.com/z/...rules
HAProxyNginx
wix.com/w/...
/w ⇒ A/z ⇒ B
![Page 47: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/47.jpg)
Why?
sample-web-servicesample-web-serviceAsample-web-servicesample-web-serviceB
Gateway
wix.com/z/...srules
Nginx
wix.com/w/...
/w ⇒ A/z ⇒ B
![Page 48: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/48.jpg)
Why?
sample-web-servicesample-web-serviceAsample-web-servicesample-web-serviceB
Gateway
wix.com/z/...rules
NginxBecause!
wix.com/w/...
/w ⇒ A/z ⇒ B
![Page 49: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/49.jpg)
Where are the rules?
sample-web-servicesample-web-serviceAsample-web-servicesample-web-serviceB
Gateway
wix.com/w/...
wix.com/z/...rules
/w ⇒ A/z ⇒ B
![Page 50: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/50.jpg)
Where are the rules?
sample-web-servicesample-web-serviceAsample-web-servicesample-web-serviceB
Gateway
wix.com/z/...rules
Source Control!
wix.com/w/...
/w ⇒ A/z ⇒ B
![Page 51: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/51.jpg)
And how does it know
where the instance are?
AA
A
B
B
B
Gateway
rules
?Host1 Host2
/w ⇒ A/z ⇒ B
![Page 52: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/52.jpg)
The Scheduler Knows
sample-web-servicesample-web-serviceAsample-web-servicesample-web-serviceB
Gateway
web-service.demo.com/w/...
web-service.demo.com/z/...rules
Mesos/
Marathon
![Page 53: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/53.jpg)
How To Implement
RPC Service
Discovery
![Page 54: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/54.jpg)
RPC Service Discovery sample-web-servicesample-web-serviceservice
sample-web-servicesample-web-servicerpc-service A
serviceA.doSomething("a", 4)
sample-web-servicesample-web-servicerpc-service B
Gateway
serviceB.doSomethingElse(4, 2)
![Page 55: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/55.jpg)
See the Resemblance?
![Page 56: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/56.jpg)
Same Difference sample-web-servicesample-web-serviceservice
sample-web-servicesample-web-servicerpc-service Asample-web-servicesample-web-servicerpc-service B
Gateway
Nginx
![Page 57: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/57.jpg)
Where are the rules? sample-web-servicesample-web-serviceservice
sample-web-servicesample-web-servicerpc-service Asample-web-servicesample-web-servicerpc-service B
Gateway
serviceB.doSomethingElse(4, 2)serviceA.doSomething("a", 4)
![Page 58: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/58.jpg)
No Rules! Conventions sample-web-servicesample-web-serviceservice
sample-web-servicesample-web-servicerpc-service Asample-web-servicesample-web-servicerpc-service B
Gateway
serviceB.doSomethingElse(4, 2)
via http://rpc.int/serviceB/...
serviceA.doSomething("a", 4)
via http://rpc.int/serviceA/...
![Page 59: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/59.jpg)
sample-web-servicesample-web-serviceservice
sample-web-servicesample-web-servicerpc-service Asample-web-servicesample-web-servicerpc-service B
Gateway
And Where Are
The Instances?
AA
A
B
B
B
?Host1 Host2
![Page 60: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/60.jpg)
sample-web-servicesample-web-serviceservice
sample-web-servicesample-web-servicerpc-service Asample-web-servicesample-web-servicerpc-service B
Gateway
Same Difference!
Mesos/
Marathon
serviceB.doSomethingElse(4, 2)
via http://rpc.int/serviceB/...serviceA.doSomething("a", 4)
via http://rpc.int/serviceA/...
![Page 61: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/61.jpg)
Let’s Recap
![Page 62: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/62.jpg)
apollo deploy A -n 2
apollo deploy B -n 2
![Page 63: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/63.jpg)
apollo deploy A -n 2 Marathon
apollo deploy B -n 2
● Please create service A
● I need two instances of this service available
at all times
● This is the docker image you need to deploy
![Page 64: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/64.jpg)
apollo deploy A -n 2 Marathon
apollo deploy B -n 2
A A
B B
![Page 65: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/65.jpg)
apollo deploy A -n 2 Marathon
apollo deploy B -n 2
A A
B B
Web Gateway
C D
wix.com/a-path
![Page 66: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/66.jpg)
apollo deploy A -n 2 Marathon
apollo deploy B -n 2
A A
B B
Web Gateway
C D
Path rules:
a-path ⇒ A
wix.com/a-path
![Page 67: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/67.jpg)
apollo deploy A -n 2 Marathon
apollo deploy B -n 2
A A
B B
RPC Gateway
Web Gateway
C D
E
b.foo()
![Page 68: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/68.jpg)
apollo deploy A -n 2 Marathon
apollo deploy B -n 2
A A
B B
RPC Gateway
Web Gateway
C D
E
http://rpc.int/B/foo
![Page 69: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/69.jpg)
apollo deploy A -n 2 Marathon
apollo deploy B -n 2
A A
B B
RPC Gateway
Web Gateway
C D
E
http://rpc.int/B/foo
![Page 70: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/70.jpg)
apollo deploy A -n 2 Marathon
apollo deploy B -n 2
A A
B B
RPC Gateway
Web Gateway
C D
E
Path rules:
a-path ⇒ A
![Page 71: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/71.jpg)
apollo deploy A -n 2 Marathon
apollo deploy B -n 2
A A
B B
RPC Gateway
Web Gateway
C D
E
Path rules:
a-path ⇒ A
![Page 72: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/72.jpg)
3. The Job
![Page 73: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/73.jpg)
We Split the Job
![Page 74: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/74.jpg)
1. System (Vagrant and Amazon)
2. Sample Web Service and RPC Service
3. Deployment via CLI
4. RPC Service Discovery
5. Web Service Discovery
Splitting the Work
![Page 75: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/75.jpg)
1. System (Vagrant and Amazon)
2. Sample Web Service and RPC Service
3. Deployment via CLI
4. RPC Service Discovery
5. Web Service Discovery
![Page 76: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/76.jpg)
System
(Vagrant and Amazon)
![Page 77: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/77.jpg)
Ansible
Scripts
VirtualBox
Vagrant VM
Mesos
Marathon
Zookeeper
...
Host1
Mesos Master
Marathon
Host2
Zookeeper
Host3
Mesos Slave
Host4
Mesos Slave
![Page 78: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/78.jpg)
1. System (Vagrant and Amazon)
2. Sample Web Service and RPC Service
3. Deployment via CLI
4. RPC Service Discovery
5. Web Service Discovery
![Page 79: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/79.jpg)
Example RPC Call
val helloServiceRpcClient = rpcClientFactory
.rpcProxyFactory.builderFor(classOf[HelloService])
.withStaticURL(new Url(s"http://${sys.env("RPC_INT")}")
.withPart("rpc-service")
.build()
helloServiceRpcClient.sayHello()
POST http://rpc.int/rpc-service/sayHello
![Page 80: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/80.jpg)
1. System (Vagrant and Amazon)
2. Sample Web Service and RPC Service
3. Deployment via CLI
4. RPC Service Discovery
5. Web Service Discovery
Splitting the Work
![Page 81: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/81.jpg)
Remember?
$ npm install -g apollo
$ apollo artifact-deploy web-service:1.5.0 -n 20
$ curl web-service.demo-domain.com/....
$ apollo artifact-deploy web-service:1.6.0 -n 30
![Page 82: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/82.jpg)
Deploying Instances To Marathon
const appId =
`/production/backend/${serviceName}`;
const appDeployResponse =marathon.client('PUT',
`/apps${appId}`, appConfig);
const appConfig = {id: appId,container: {
type: 'DOCKER',docker: {
image: `${serviceName)}:${version}`,}
},env: {RPC_INT: 'localhost:9090'},labels: {
microService: true,serviceName: serviceName
},healthChecks: [{
"path": '/health/is_alive'}]"cpus": 0.2,"mem": 200,"instances": parseInt(numberOfInstances)
};
![Page 83: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/83.jpg)
Marathon...
● Sees how many instances needs to be deployed
● Uses Mesos to deploy the correct number of them on the
hosts using Docker
● Waits for them to be alive using the health check
● The configuration is not a one-off
○ Marathon will always strive for it
○ If something dies (a host or an instance),
Marathon will regenerate
![Page 84: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/84.jpg)
Marathon...
● Sees how many instances needs to be deployed
● Uses Mesos to deploy the correct number of them on the
hosts using Docker
● Waits for them to be alive using the health check
● The configuration is not a one-off
○ Marathon will always strive for it
○ If something dies (a host or an instance),
Marathon will regenerate
![Page 85: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/85.jpg)
Marathon...
● Sees how many instances needs to be deployed
● Uses Mesos to deploy the correct number of them on the
hosts using Docker
● Waits for them to be alive using the health check
● The configuration is not a one-off
○ Marathon will always strive for it
○ If something dies (a host or an instance),
Marathon will regenerate
![Page 86: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/86.jpg)
Marathon...
● Sees how many instances needs to be deployed
● Uses Mesos to deploy the correct number of them on the
hosts using Docker
● Waits for them to be alive using the health check
● The configuration is not a one-off
○ Marathon will always strive for it
○ If something dies (a host or an instance),
Marathon will regenerate
![Page 87: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/87.jpg)
What About Upgrading?
$ npm install -g apollo
$ apollo artifact-deploy web-service:1.5.0 -n 20
$ curl web-service.demo-domain.com/....
$ apollo artifact-deploy web-service:1.6.0 -n 30
![Page 88: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/88.jpg)
Upgrading Instances
const appId =
`/production/backend/${serviceName}`;
const appDeployResponse =marathon.client('PUT',
`/apps${appId}`, appConfig);
const appConfig = {id: appId,container: {
type: 'DOCKER',docker: {
image: `${serviceName)}:${version}`,}
},env: {RPC_INT: 'localhost:9090'},labels: {
microService: true,serviceName: serviceName
},healthChecks: [{
"path": '/health/is_alive'}]"cpus": 0.2,"mem": 200,"instances": parseInt(numberOfInstances)
};
![Page 89: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/89.jpg)
Marathon...
● Notices the configuration changed
● Strives for it to be true
● Uses Blue/Green Deployment to ensure constant uptime
![Page 90: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/90.jpg)
Marathon...
● Notices the configuration changed
● Strives for it to be true
● Uses Blue/Green Deployment to ensure constant uptime
![Page 91: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/91.jpg)
Marathon...
● Notices the configuration changed
● Strives for it to be true
● Uses Blue/Green Deployment to ensure constant uptime
![Page 92: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/92.jpg)
1. System (Vagrant and Amazon)
2. Sample Web Service and RPC Service
3. Deployment via CLI
4. RPC Service Discovery
5. Web Service Discovery
The First Three Tasks
![Page 93: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/93.jpg)
1. System (Vagrant and Amazon)
2. Sample Web Service and RPC Service
3. Deployment via CLI
4. RPC Service Discovery
5. Web Service Discovery
The First Three Tasks
![Page 94: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/94.jpg)
1. System (Vagrant and Amazon)
2. Sample Web Service and RPC Service
3. Deployment via CLI
4. RPC Service Discovery
5. Web Service Discovery
And What About The Rest?
![Page 95: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/95.jpg)
4. The Change of Plan
![Page 96: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/96.jpg)
3rd Party Service
Discovery!
![Page 97: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/97.jpg)
So What Else?
![Page 98: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/98.jpg)
Staging!
![Page 99: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/99.jpg)
Production is just
another environment
![Page 100: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/100.jpg)
Environments
C
D E
E
E
C
B
B
B
E
C
C
C A
A
D
C
C
A
A
A
E
C
B
A
A
E
ED
D
C
BB
B
E
E
A
E
D C
C
B
B
B
B
C
A
D
B
DB
C
C
A
A A
D
E
D BC
C C
A A
E
E
D D
![Page 101: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/101.jpg)
How does this look inside the CLI?
$ npm install -g apollo
$ apollo artifact-deploy web-service:1.5.0
-e stage1 -n 20
$ apollo artifact-deploy web-service:1.6.0 -n 1
--testbed
$ apollo artifact-deploy web-service:1.6.0 -n 30
![Page 102: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/102.jpg)
And from the browser?
sample-web-servicesample-web-serviceweb-service
sample-web-servicesample-web-servicerpc-servicemysql1
stage1.wix.com/w/...
![Page 103: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/103.jpg)
Web Service Discovery
sample-web-servicesample-web-serviceWeb-service A
(stage1) sample-web-servicesample-web-serviceWeb-service A
(production)
Proxy/Load
Balancer
stage1.wix.com/w/...
wix.com/w/...rules
![Page 104: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/104.jpg)
And RPC Services?
sample-web-servicesample-web-serviceweb-service
sample-web-servicesample-web-servicerpc-service Amysql1
serviceA.doSomething("a", 4)
![Page 105: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/105.jpg)
RPC Service Discovery sample-web-servicesample-web-serviceservice
sample-web-servicesample-web-servicerpc-service Asample-web-servicesample-web-servicerpc-service A
Proxy/Load
Balancer
serviceA.doSomething("a", 4)
via http://rpc.int/serviceA/...
serviceA.doSomething("a", 4)
via http://stage1.rpc.int/serviceA/...
![Page 106: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/106.jpg)
Example RPC Call
val helloServiceRpcClient = rpcClientFactory
.rpcProxyFactory.builderFor(classOf[HelloService])
.withStaticURL(
new Url(s"http://${sys.env("RPC_INT")}")
.withPart("rpc-service")
.build()
helloServiceRpcClient.sayHello()
![Page 107: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/107.jpg)
And 3rd Party
Services?
sample-web-servicesample-web-serviceweb-service
sample-web-servicesample-web-servicerpc-servicemysql1
Select * from ...
![Page 108: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/108.jpg)
5. It All Comes Together
![Page 109: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/109.jpg)
Same Difference
![Page 110: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/110.jpg)
nginx.conf
nginx
manager
Marathon
![Page 111: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/111.jpg)
nginx.conf
nginx
manager
Marathon
![Page 112: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/112.jpg)
Remember?
const appId =
`/production/backend/${serviceName}`;
const appDeployResponse =marathon.client('PUT',
`/apps${appId}`, appConfig);
const appConfig = {id: appId,container: {
type: 'DOCKER',docker: {
image: ${serviceName)}:${version}`,}
},env: {RPC_INT: ‘localhost:9090’, ...},labels: {
microService: true,serviceName: serviceName
},healthChecks: [{
"path": '/health/is_alive'}]"cpus": 0.2,"mem": 200,"instances": parseInt(numberOfInstances)
};
![Page 113: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/113.jpg)
nginx.conf
nginx
manager
Marathon
![Page 114: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/114.jpg)
nginx.conf
nginx
manager
Marathon
![Page 115: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/115.jpg)
nginx.conf
nginx
manager
Marathon
![Page 116: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/116.jpg)
Language?
![Page 117: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/117.jpg)
Bash is easier
![Page 118: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/118.jpg)
Generating nginx.conf from information in Marathon
request_url="http://$marathon_host/v2/apps?embed=app.tasks"
json=$(curl --fail --silent $request_url)
environments=$(echo $json | \
jq -r '[.apps[] | .labels.environment] | unique)
for environment in $environments; doexport environmentapps=$(echo $json | jq -r '.apps[] | \
select(.labels.environment == env.environment)')app_ids=$(echo $apps | jq -r '.id' | \
sed 's/-testbed//g' | sort | uniq)
for app_id in $app_ids; do....
donedone
app=$(echo $apps | jq -r 'select(.id == env.app_id), select(.id == env.app_id + "-testbed")')
artifactId=$(echo $app | jq -r '.labels.artifactId' | uniq) servers=$(echo $app | jq -r '.tasks[] |select(.healthCheckResults[0].alive == true) | .host + ":" + (.ports[0] | tostring)')
# Generate the part of the nginx.conf for each server where this app is in
![Page 119: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/119.jpg)
1. System (Vagrant and Amazon)
2. Sample Web Service and RPC Service
3. Deployment via CLI
4. RPC Service Discovery
5. Web Service Discovery
The First Three Tasks
![Page 120: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/120.jpg)
Let’s Recap
![Page 121: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/121.jpg)
apollo deploy A -n 2 -e s
apollo deploy B -n 2 -e s
![Page 122: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/122.jpg)
apollo deploy A -n 2 -e s Marathon
apollo deploy B -n 2 -e s
● # of instances
● RPC_INT pointing to s.rpc.int.
● Env variables for each 3rd party service
● Docker image to use
POST json
configuration
![Page 123: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/123.jpg)
apollo deploy A -n 2 Marathon
apollo deploy B -n 2
A A
B B
![Page 124: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/124.jpg)
Marathon
A A
B B
RPC Gateway
Web Gateway Path rules:
a-path ⇒ A
nginx.conf
nginx.conf
![Page 125: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/125.jpg)
Marathon
A A
B B
Web Gateway
Nginx
C D
s.wix.com/a-pathnginx.conf
![Page 126: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/126.jpg)
Marathon
A A
B B
C D
s.wix.com/a-pathnginx.conf
Web Gateway
Nginx
![Page 127: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/127.jpg)
Marathon
A A
B B
RPC Gateway
Nginx
C D
E
b.foo()
Web Gateway
Nginx
nginx.conf
![Page 128: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/128.jpg)
Marathon
A A
B B
Web Gateway
C D
E
RPC Gateway
Nginxnginx.conf
http://s.rpc.int/B/foo
![Page 129: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/129.jpg)
Marathon
A A
B B
Web Gateway
C D
E
RPC Gateway
Nginxnginx.conf
![Page 130: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/130.jpg)
apollo deploy A -n 2 Marathon
apollo deploy B -n 2
A A
B B
RPC Gateway
Web Gateway
C D
E
Path rules:
a-path ⇒ A
nginx.conf
nginx.conf
![Page 131: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/131.jpg)
6. Epilog
![Page 132: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/132.jpg)
We won!
![Page 133: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/133.jpg)
End Result
● Micro-services Infra, supporting…
● Red-green deployment
● 3rd Party Services
● Staging environments
● Built in 6 days
![Page 134: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/134.jpg)
And on the 7th Day?
![Page 135: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/135.jpg)
We Rested
![Page 136: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/136.jpg)
We’re Jewish, Aren’t We?
![Page 137: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/137.jpg)
7. Box Office Results
![Page 138: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/138.jpg)
I’ve Got Some Good News and Some Bad News
● Bad news: it never got released at Wix
● Good news: I got it working at my new company: Applitools
● And it took me 3 days!○ Including tests
● How?
![Page 139: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/139.jpg)
1. System (Vagrant and Amazon)
2. Sample Web Service and RPC Service
3. Deployment via CLI
4. RPC Service Discovery
5. Web Service Discovery
Remember the Work?
![Page 140: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/140.jpg)
1. System (Vagrant and Amazon)
2. Sample Web Service and RPC Service
3. Deployment via CLI
4. RPC Service Discovery
5. Web Service Discovery
Remember the Work?
![Page 141: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/141.jpg)
How? Kubernetes!
![Page 142: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/142.jpg)
● Instead of Vagrant, minikube
● In Google Cloud and Azure - Managed
Kubernetes
● Amazon coming soon?
System (Vagrant and Amazon)
![Page 143: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/143.jpg)
● I don’t need a sample - I already wrote my
own!
Sample Web Service and RPC Service
![Page 144: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/144.jpg)
● Instead of:
○ apollo web-service:1.2.0 -n 2 -e stage
● I do:
○ kdeploy web-service:1.2.0 -n 2 -e stage
Deployment via CLI
![Page 145: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/145.jpg)
● RPC Service Discovery
○ Built into Kubernetes
● Web Service Discovery
○ Built into Kubernetes
Service Discovery
![Page 146: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/146.jpg)
1. System (Vagrant and Amazon)
2. Sample Web Service and RPC Service
3. Deployment via CLI
4. RPC Service Discovery
5. Web Service Discovery
So Kubernetes Saves a Lot of Time!
![Page 147: How To Build A Micro-Services Infrastructure in 7 Days€¦ · Micro-Services Infrastructure in 7 Days Gil Tayar, November 2017 @giltayar. Wix Internal Hackathon - December 2015](https://reader036.vdocument.in/reader036/viewer/2022081516/605719aaa68e5f2d63268928/html5/thumbnails/147.jpg)
Thank You
@giltayar