SLIDE 1
Micro-‑service ¡Developer ¡Experience ¡ ¡ Node ¡Interac6ve ¡2015 ¡
Peter ¡Elger ¡ @pelger ¡ ¡
SLIDE 2 Micro-‑services ¡
- NOT ¡a ¡new ¡concept ¡-‑ ¡See ¡‘unix’ ¡J ¡
- Small, ¡focused, ¡decoupled ¡components ¡
- Easily ¡understood ¡
- Rapid ¡itera6ve ¡deployment ¡
- Architectural ¡style ¡par6cularly ¡suited ¡to ¡
node.js ¡
SLIDE 3
That’s ¡Awesome! ¡But… ¡
SLIDE 4
Shell ¡Hell? ¡
SLIDE 5 Tradeoffs ¡
– Smaller ¡units ¡of ¡code ¡ – Easier ¡to ¡reason ¡about ¡in ¡isola6on ¡ – Easier ¡to ¡test ¡in ¡isola6on ¡ – Rapid ¡incremental ¡deployment ¡ ¡ ¡
– Large ¡amount ¡of ¡code ¡ – Much ¡more ¡complex ¡to ¡reason ¡about ¡ – More ¡difficult ¡to ¡test ¡in ¡isola6on ¡ – Highly ¡coupled ¡slow, ¡risky ¡deployments ¡
SLIDE 6 Tradeoffs ¡
– Harder ¡to ¡run ¡a ¡system ¡in ¡development ¡
– Trickier ¡to ¡apply ¡debuggers ¡and ¡tooling ¡ ¡
– Easier ¡to ¡run ¡a ¡system ¡in ¡development ¡ ¡
– Easier ¡to ¡apply ¡debuggers ¡and ¡tooling ¡
SLIDE 7
Op6ons? ¡
SLIDE 8 Just ¡develop ¡services ¡in ¡isola6on? ¡
- Developing ¡single ¡services ¡is ¡simple ¡
– Easy ¡to ¡unit ¡test ¡ – 100% ¡line ¡coverage ¡is ¡usually ¡achievable ¡
- Then ¡integrate ¡on ¡staging ¡or ¡produc6on ¡only. ¡
¡
SLIDE 9 Script ¡it ¡
- Develop ¡custom ¡shell ¡scripts ¡to ¡start ¡and ¡stop ¡
the ¡system ¡under ¡development ¡
– Used ¡this ¡on ¡several ¡projects ¡
- However ¡there ¡is ¡addi6onal ¡overhead ¡in ¡
keeping ¡scripts ¡current ¡
- Also ¡need ¡to ¡ensure ¡that ¡developer ¡machines ¡
have ¡the ¡same ¡infrastructure ¡
SLIDE 10 Use ¡containers? ¡
- Tools ¡like ¡docker-‑compose ¡allow ¡us ¡to ¡start ¡and ¡
stop ¡mul6ple ¡containers ¡(i.e. ¡services) ¡in ¡one ¡go ¡
- Also ¡allow ¡us ¡to ¡define ¡the ¡infrastructure ¡
requirements ¡cleanly ¡
– However ¡the ¡container ¡build ¡cycle ¡can ¡be ¡slow ¡and ¡ frustra6ng ¡ – Environmental ¡differences ¡between ¡development ¡and ¡ produc6on ¡can ¡cause ¡fric6on ¡ – Debugging ¡using ¡containers ¡can ¡be ¡a ¡challenge ¡to ¡ setup ¡
SLIDE 11
Three ¡strikes ¡and ¡automate… ¡
h_ps://github.com/apparatus/fuge ¡
SLIDE 12 Goals ¡
- Provide ¡a ¡tool ¡that ¡generates ¡micro-‑service ¡
scaffolding ¡
¡
- Provide ¡a ¡run ¡6me ¡environment ¡for ¡micro-‑
service ¡development ¡that ¡supports ¡
– Rapid ¡development ¡ – Reduces ¡container ¡fric6on ¡ – Eases ¡debugging ¡
SLIDE 13
Stack ¡
SLIDE 14
Stack ¡
SLIDE 15
Code ¡6me!! ¡
fuge generate system
SLIDE 16
System ¡Genera6on ¡
SLIDE 17
System ¡Genera6on ¡
SLIDE 18 System ¡Genera6on ¡
- Uses ¡Dockerfile ¡and ¡docker-‑compose ¡syntax ¡
- Fuge ¡uses ¡these ¡files ¡to ¡run ¡local ¡processes ¡
and ¡containers ¡ ¡
SLIDE 19
System ¡execu6on ¡
Fuge shell compose-dev.yml
SLIDE 20
Add ¡a ¡service ¡
¡ ¡
fuge generate service
SLIDE 21
Add ¡a ¡service ¡
SLIDE 22 Add ¡Infrastructure ¡
- docker ¡pull ¡mongo ¡
- Update ¡compose-‑dev.yml ¡
- Add ¡some ¡code ¡to ¡service1 ¡
- restart ¡
SLIDE 23
Add ¡Infrastructure ¡
SLIDE 24 Proxy ¡
- We ¡are ¡now ¡recording ¡data ¡into ¡MongoDB ¡
running ¡in ¡a ¡container ¡from ¡a ¡process ¡ ¡
- Fuge ¡will ¡proxy ¡connec6ons ¡between ¡processes ¡
and ¡containers ¡
– Without ¡our ¡code ¡needing ¡to ¡be ¡configured ¡
¡
- Mixing ¡containers ¡and ¡processes ¡with ¡reduced ¡
fric6on ¡
SLIDE 25 Logging ¡
- For ¡convenience ¡
- Fuge ¡creates ¡per ¡service ¡logs ¡at ¡
– ./fuge/log/<servicename>.log ¡ ¡
– Search ¡by ¡service ¡or ¡over ¡all ¡
SLIDE 26 Debugging ¡
- Experimental ¡
- Fuge ¡provides ¡a ¡debug ¡command ¡
– Currently ¡requires ¡node-‑debug ¡installed ¡
- A_ach ¡a ¡debugger ¡to ¡a ¡specific ¡service ¡
SLIDE 27
Retrofit ¡-‑ ¡Nodezoo ¡
SLIDE 28 Retrofit ¡-‑ ¡Nodezoo ¡
- Exis6ng ¡system ¡
- Added ¡compose ¡yml ¡
– Broken ¡out ¡infrastructure ¡from ¡code ¡
- Docker-‑compose ¡runs: ¡
– Redis, ¡elas6csearch, ¡influx ¡and ¡beanstalkd ¡ ¡
– Frontend ¡and ¡services ¡
SLIDE 29 Summary ¡
- Developing ¡micro-‑services ¡presents ¡its ¡own ¡
unique ¡challenges ¡
¡
SLIDE 30
Contributors ¡
SLIDE 31 Thank ¡you! ¡
¡ ¡
- h_ps://github.com/apparatus/fuge ¡
- npm ¡install ¡–g ¡fuge ¡
- @pelger ¡