Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.51 KB | None | 0 0
  1. my
  2. name
  3. is
  4. Wyatt
  5. Perl
  6. I'm
  7. a
  8. product
  9. engineer
  10. at
  11. Giant
  12. and
  13. you
  14. can
  15. find
  16. links
  17. to
  18. the
  19. slides
  20. and
  21. everything
  22. I'm
  23. going
  24. to
  25. talk
  26. about
  27. today
  28. at
  29. my
  30. website
  31. at
  32. JSC
  33. ich
  34. komm
  35. slash
  36. nerd
  37. summit
  38. so
  39. I
  40. want
  41. to
  42. start
  43. by
  44. telling
  45. a
  46. children's
  47. story
  48. actually
  49. think
  50. that
  51. children's
  52. stories
  53. are
  54. pretty
  55. useful
  56. I
  57. learned
  58. quite
  59. a
  60. bit
  61. whenever
  62. I'm
  63. reading
  64. them
  65. to
  66. my
  67. kids
  68. for
  69. example
  70. I
  71. was
  72. reading
  73. llama
  74. llama
  75. red
  76. pajama
  77. and
  78. that
  79. taught
  80. me
  81. how
  82. to
  83. do
  84. callbacks
  85. or
  86. Chicken
  87. Little
  88. actually
  89. taught
  90. me
  91. about
  92. cascading
  93. failure
  94. and
  95. so
  96. I
  97. took
  98. Chicken
  99. Little
  100. and
  101. I
  102. definitely
  103. took
  104. liberties
  105. with
  106. it
  107. so
  108. I
  109. have
  110. an
  111. adaptation
  112. of
  113. Chicken
  114. Little
  115. and
  116. I'm
  117. calling
  118. it
  119. chicken
  120. micro
  121. so
  122. let's
  123. let's
  124. begin
  125. one
  126. day
  127. a
  128. chicken
  129. micro
  130. was
  131. making
  132. a
  133. request
  134. to
  135. the
  136. corn
  137. server
  138. when
  139. boom
  140. the
  141. request
  142. timed
  143. out
  144. goodness
  145. gracious
  146. the
  147. server's
  148. must
  149. be
  150. down
  151. I
  152. must
  153. go
  154. and
  155. tell
  156. the
  157. system
  158. operator
  159. so
  160. chicken
  161. micro
  162. went
  163. along
  164. until
  165. she
  166. came
  167. to
  168. Boxey
  169. Loxy
  170. where
  171. are
  172. you
  173. going
  174. in
  175. such
  176. a
  177. hurry
  178. asked
  179. Foxy
  180. Loxy
  181. I'm
  182. going
  183. to
  184. tell
  185. the
  186. operator
  187. that
  188. the
  189. servers
  190. are
  191. down
  192. I
  193. made
  194. a
  195. request
  196. and
  197. never
  198. got
  199. a
  200. response
  201. oh
  202. dear
  203. I'll
  204. go
  205. with
  206. you
  207. so
  208. chicken
  209. micro
  210. and
  211. boxy
  212. Loxy
  213. went
  214. along
  215. until
  216. they
  217. came
  218. to
  219. robot
  220. Rob
  221. where
  222. are
  223. you
  224. going
  225. in
  226. such
  227. a
  228. hurry
  229. asked
  230. robot
  231. Rob
  232. we're
  233. going
  234. to
  235. tell
  236. the
  237. operator
  238. that
  239. the
  240. servers
  241. are
  242. down
  243. chicken
  244. micro
  245. made
  246. a
  247. request
  248. to
  249. never
  250. got
  251. a
  252. response
  253. I'll
  254. go
  255. with
  256. you
  257. so
  258. chicken
  259. micro
  260. Foxy
  261. Loxy
  262. and
  263. robot
  264. Rob
  265. made
  266. it
  267. to
  268. the
  269. system
  270. operator
  271. I
  272. made
  273. a
  274. request
  275. to
  276. the
  277. corn
  278. server
  279. and
  280. the
  281. request
  282. timed
  283. out
  284. the
  285. servers
  286. are
  287. down
  288. Oh
  289. chicken
  290. micro
  291. the
  292. servers
  293. are
  294. not
  295. down
  296. but
  297. the
  298. server
  299. the
  300. load
  301. balancer
  302. sent
  303. you
  304. to
  305. was
  306. under
  307. heavy
  308. load
  309. please
  310. try
  311. your
  312. request
  313. again
  314. so
  315. we
  316. can
  317. learn
  318. some
  319. lessons
  320. from
  321. chicken
  322. micro
  323. for
  324. example
  325. if
  326. your
  327. server
  328. is
  329. overloaded
  330. respond
  331. with
  332. a
  333. 503
  334. and
  335. ideally
  336. your
  337. load
  338. balancer
  339. or
  340. whatever
  341. will
  342. take
  343. you
  344. out
  345. of
  346. rotation
  347. but
  348. even
  349. if
  350. we
  351. did
  352. have
  353. a
  354. load
  355. balancer
  356. in
  357. the
  358. mix
  359. how
  360. would
  361. chicken
  362. micro
  363. know
  364. that
  365. the
  366. next
  367. request
  368. would
  369. even
  370. succeed
  371. because
  372. chicken
  373. micro
  374. doesn't
  375. know
  376. the
  377. health
  378. of
  379. the
  380. servers
  381. behind
  382. the
  383. load
  384. balancer
  385. and
  386. so
  387. this
  388. brings
  389. me
  390. to
  391. a
  392. point
  393. where
  394. as
  395. you're
  396. moving
  397. from
  398. micro
  399. services
  400. and
  401. you're
  402. trying
  403. to
  404. re
  405. are
  406. c't
  407. X
  408. or
  409. monolith
  410. sometimes
  411. you
  412. you
  413. leak
  414. over
  415. your
  416. monolithic
  417. architecture
  418. and
  419. this
  420. can
  421. bring
  422. about
  423. some
  424. of
  425. the
  426. same
  427. issues
  428. you
  429. had
  430. with
  431. your
  432. monolith
  433. but
  434. before
  435. I
  436. get
  437. too
  438. far
  439. ahead
  440. of
  441. myself
  442. I
  443. definitely
  444. need
  445. to
  446. clarify
  447. what
  448. I
  449. mean
  450. by
  451. micro
  452. service
  453. because
  454. there's
  455. lots
  456. of
  457. definitions
  458. people
  459. have
  460. varying
  461. thoughts
  462. on
  463. it
  464. but
  465. when
  466. I
  467. describe
  468. a
  469. micro
  470. service
  471. I'm
  472. talking
  473. about
  474. a
  475. small
  476. service
  477. and
  478. ideally
  479. it's
  480. the
  481. decomposed
  482. from
  483. a
  484. monolith
  485. and
  486. I
  487. think
  488. most
  489. importantly
  490. each
  491. service
  492. needs
  493. to
  494. be
  495. able
  496. to
  497. be
  498. isolated
  499. and
  500. independently
  501. deployable
  502. and
  503. lastly
  504. you
  505. should
  506. be
  507. stateless
  508. so
  509. that
  510. it's
  511. easy
  512. to
  513. scale
  514. out
  515. your
  516. services
  517. and
  518. from
  519. these
  520. characteristics
  521. we
  522. can
  523. get
  524. a
  525. lot
  526. of
  527. benefits
  528. because
  529. it's
  530. able
  531. to
  532. be
  533. independently
  534. deployed
  535. you
  536. are
  537. able
  538. to
  539. embrace
  540. failure
  541. so
  542. if
  543. your
  544. other
  545. dependencies
  546. are
  547. down
  548. it
  549. won't
  550. impact
  551. you
  552. and
  553. from
  554. this
  555. you
  556. can
  557. actually
  558. move
  559. very
  560. quickly
  561. you
  562. can
  563. deliver
  564. lots
  565. of
  566. business
  567. value
  568. if
  569. something
  570. doesn't
  571. work
  572. out
  573. you
  574. can
  575. just
  576. tear
  577. down
  578. that
  579. service
  580. and
  581. try
  582. again
  583. because
  584. everything
  585. is
  586. so
  587. tiny
  588. ideally
  589. and
  590. able
  591. to
  592. be
  593. independently
  594. deployable
  595. but
  596. there
  597. are
  598. definitely
  599. some
  600. anti
  601. patterns
  602. that
  603. we
  604. run
  605. into
  606. especially
  607. as
  608. we
  609. move
  610. from
  611. the
  612. monolith
  613. to
  614. the
  615. micro
  616. services
  617. so
  618. there's
  619. a
  620. very
  621. helpful
  622. book
  623. by
  624. Mark
  625. Richards
  626. called
  627. micro
  628. services
  629. anti
  630. patterns
  631. and
  632. pitfalls
  633. I
  634. encourage
  635. you
  636. to
  637. go
  638. check
  639. it
  640. out
  641. at
  642. storm
  643. o'reilly
  644. and
  645. it's
  646. actually
  647. free
  648. so
  649. even
  650. more
  651. reason
  652. but
  653. I
  654. want
  655. to
  656. focus
  657. on
  658. a
  659. couple
  660. anti
  661. patterns
  662. today
  663. so
  664. the
  665. balancer
  666. between
  667. micro-services
  668. and
  669. then
  670. how
  671. startup
  672. order
  673. can
  674. matter
  675. so
  676. if
  677. we
  678. look
  679. at
  680. the
  681. situation
  682. with
  683. chicken
  684. micro
  685. where
  686. the
  687. load
  688. balancer
  689. was
  690. between
  691. the
  692. micro-services
  693. chicken
  694. micro
  695. had
  696. a
  697. timeout
  698. and
  699. how
  700. would
  701. chicken
  702. micro
  703. know
  704. when
  705. to
  706. make
  707. the
  708. next
  709. request
  710. do
  711. you
  712. just
  713. retry
  714. immediately
  715. well
  716. how
  717. do
  718. you
  719. know
  720. that
  721. there
  722. are
  723. other
  724. servers
  725. that
  726. are
  727. even
  728. healthy
  729. behind
  730. that
  731. load
  732. balancer
  733. so
  734. you
  735. have
  736. that
  737. disconnect
  738. when
  739. you
  740. have
  741. a
  742. load
  743. balancer
  744. situated
  745. between
  746. your
  747. micro
  748. services
  749. and
  750. even
  751. if
  752. you
  753. had
  754. a
  755. 503
  756. response
  757. telling
  758. you
  759. like
  760. retry
  761. in
  762. a
  763. minute
  764. how
  765. would
  766. you
  767. know
  768. that
  769. that
  770. would
  771. succeed
  772. or
  773. maybe
  774. you
  775. could
  776. have
  777. just
  778. reached
  779. right
  780. immediately
  781. because
  782. there
  783. could
  784. be
  785. other
  786. servers
  787. that
  788. are
  789. healthy
  790. and
  791. lastly
  792. the
  793. startup
  794. order
  795. matters
  796. is
  797. another
  798. anti-pattern
  799. I
  800. think
  801. because
  802. everything
  803. should
  804. be
  805. independently
  806. deployable
  807. you
  808. really
  809. shouldn't
  810. be
  811. tied
  812. to
  813. assuming
  814. that
  815. your
  816. database
  817. is
  818. up
  819. for
  820. example
  821. so
  822. in
  823. this
  824. this
  825. code
  826. snippet
  827. we're
  828. trying
  829. to
  830. make
  831. a
  832. connection
  833. to
  834. my
  835. sequel
  836. and
  837. we're
  838. binding
  839. herself
  840. to
  841. a
  842. DB
  843. host
  844. through
  845. the
  846. environment
  847. variable
  848. another
  849. issue
  850. with
  851. this
  852. too
  853. is
  854. if
  855. that
  856. host
  857. changes
  858. you're
  859. gonna
  860. have
  861. to
  862. restart
  863. the
  864. entire
  865. process
  866. because
  867. it's
  868. an
  869. environment
  870. variable
  871. and
  872. then
  873. if
  874. the
  875. database
  876. is
  877. not
  878. up
  879. you're
  880. not
  881. really
  882. handling
  883. into
  884. that
  885. so
  886. you
  887. have
  888. to
  889. think
  890. about
  891. things
  892. differently
  893. you
  894. have
  895. to
  896. really
  897. are
  898. assume
  899. that
  900. not
  901. everything
  902. is
  903. going
  904. to
  905. be
  906. working
  907. whenever
  908. your
  909. application
  910. starts
  911. or
  912. when
  913. your
  914. micro
  915. service
  916. starts
  917. goodness
  918. gracious
  919. are
  920. there
  921. any
  922. patterns
  923. that
  924. can
  925. help
  926. me
  927. well
  928. fortunately
  929. there
  930. are
  931. so
  932. the
  933. one
  934. I
  935. want
  936. to
  937. focus
  938. on
  939. is
  940. the
  941. autopilot
  942. pattern
  943. it
  944. is
  945. not
  946. geared
  947. specifically
  948. for
  949. micro
  950. services
  951. but
  952. it
  953. actually
  954. lends
  955. itself
  956. well
  957. to
  958. helping
  959. with
  960. the
  961. issues
  962. that
  963. I
  964. highlighted
  965. so
  966. the
  967. main
  968. goals
  969. of
  970. the
  971. autopilot
  972. pattern
  973. or
  974. that
  975. you're
  976. able
  977. to
  978. build
  979. applications
  980. that
  981. can
  982. be
  983. deployed
  984. and
  985. scaled
  986. very
  987. easily
  988. easily
  989. your
  990. application
  991. and
  992. the
  993. workflow
  994. that
  995. you
  996. used
  997. to
  998. create
  999. that
  1000. application
  1001. should
  1002. work
  1003. the
  1004. same
  1005. on
  1006. your
  1007. development
  1008. laptop
  1009. as
  1010. any
  1011. it
  1012. should
  1013. work
  1014. the
  1015. same
  1016. in
  1017. any
  1018. cloud
  1019. or
  1020. data
  1021. center
  1022. and
  1023. you
  1024. shouldn't
  1025. be
  1026. tied
  1027. to
  1028. a
  1029. specific
  1030. cloud
  1031. or
  1032. infrastructure
  1033. and
  1034. so
  1035. we
  1036. do
  1037. have
  1038. a
  1039. website
  1040. explaining
  1041. more
  1042. about
  1043. the
  1044. autopilot
  1045. pattern
  1046. just
  1047. autopilot
  1048. patterned
  1049. at
  1050. i/o
  1051. I
  1052. encourage
  1053. you
  1054. to
  1055. check
  1056. that
  1057. out
  1058. we
  1059. also
  1060. have
  1061. quite
  1062. a
  1063. few
  1064. example
  1065. applications
  1066. so
  1067. we
  1068. have
  1069. a
  1070. autopilot
  1071. pattern
  1072. github
  1073. organization
  1074. with
  1075. examples
  1076. of
  1077. MongoDB
  1078. my
  1079. sequel
  1080. influx
  1081. and
  1082. then
  1083. we
  1084. even
  1085. have
  1086. full
  1087. blueprint
  1088. applications
  1089. like
  1090. WordPress
  1091. that
  1092. are
  1093. using
  1094. this
  1095. pattern
  1096. and
  1097. typically
  1098. all
  1099. of
  1100. those
  1101. examples
  1102. that
  1103. we
  1104. have
  1105. are
  1106. using
  1107. docker
  1108. and
  1109. containers
  1110. and
  1111. to
  1112. do
  1113. that
  1114. we
  1115. have
  1116. a
  1117. tool
  1118. a
  1119. free
  1120. and
  1121. open
  1122. source
  1123. tool
  1124. called
  1125. container
  1126. pilot
  1127. which
  1128. I'll
  1129. talk
  1130. about
  1131. in
  1132. a
  1133. little
  1134. bit
  1135. but
  1136. because
  1137. we
  1138. don't
  1139. have
  1140. that
  1141. load
  1142. balancer
  1143. between
  1144. the
  1145. services
  1146. we
  1147. do
  1148. need
  1149. a
  1150. way
  1151. to
  1152. discover
  1153. you
  1154. know
  1155. what
  1156. services
  1157. are
  1158. where
  1159. and
  1160. if
  1161. they're
  1162. healthy
  1163. or
  1164. not
  1165. and
  1166. so
  1167. to
  1168. do
  1169. that
  1170. we
  1171. use
  1172. console
  1173. and
  1174. we
  1175. also
  1176. because
  1177. we're
  1178. using
  1179. console
  1180. don't
  1181. have
  1182. to
  1183. expose
  1184. any
  1185. health
  1186. checks
  1187. outside
  1188. of
  1189. the
  1190. container
  1191. so
  1192. this
  1193. makes
  1194. it
  1195. very
  1196. easy
  1197. to
  1198. to
  1199. container
  1200. eyes
  1201. and
  1202. container
  1203. pilot
  1204. eyes
  1205. I
  1206. guess
  1207. the
  1208. the
  1209. databases
  1210. so
  1211. you
  1212. can
  1213. have
  1214. your
  1215. health
  1216. check
  1217. query
  1218. your
  1219. database
  1220. and
  1221. make
  1222. sure
  1223. everything
  1224. is
  1225. working
  1226. correctly
  1227. and
  1228. report
  1229. back
  1230. to
  1231. a
  1232. console
  1233. that
  1234. you're
  1235. you're
  1236. healthy
  1237. so
  1238. to
  1239. kind
  1240. of
  1241. explain
  1242. more
  1243. about
  1244. what
  1245. this
  1246. actually
  1247. means
  1248. in
  1249. practice
  1250. I
  1251. have
  1252. a
  1253. node
  1254. example
  1255. so
  1256. I'm
  1257. using
  1258. --happy
  1259. which
  1260. is
  1261. a
  1262. wonderful
  1263. module
  1264. I
  1265. hope
  1266. you
  1267. all
  1268. check
  1269. it
  1270. out
  1271. if
  1272. you
  1273. haven't
  1274. already
  1275. using
  1276. piloted
  1277. which
  1278. I
  1279. wrote
  1280. specifically
  1281. to
  1282. work
  1283. with
  1284. this
  1285. pattern
  1286. and
  1287. then
  1288. rec
  1289. for
  1290. making
  1291. requests
  1292. so
  1293. this
  1294. is
  1295. the
  1296. the
  1297. diagram
  1298. of
  1299. the
  1300. application
  1301. I'm
  1302. going
  1303. to
  1304. show
  1305. you
  1306. you
  1307. don't
  1308. need
  1309. to
  1310. understand
  1311. all
  1312. of
  1313. it
  1314. but
  1315. just
  1316. the
  1317. general
  1318. idea
  1319. is
  1320. that
  1321. we
  1322. have
  1323. IOT
  1324. sensor
  1325. data
  1326. coming
  1327. in
  1328. and
  1329. it's
  1330. pushed
  1331. to
  1332. Nats
  1333. which
  1334. is
  1335. a
  1336. message
  1337. queuing
  1338. system
  1339. and
  1340. then
  1341. we
  1342. have
  1343. three
  1344. workers
  1345. pulling
  1346. that
  1347. sensor
  1348. data
  1349. off
  1350. humidity
  1351. in
  1352. motion
  1353. and
  1354. temperature
  1355. and
  1356. that
  1357. pushes
  1358. it
  1359. to
  1360. the
  1361. serializer
  1362. which
  1363. is
  1364. then
  1365. saved
  1366. to
  1367. influx
  1368. DB
  1369. and
  1370. on
  1371. the
  1372. front
  1373. end
  1374. we
  1375. have
  1376. the
  1377. front
  1378. end
  1379. which
  1380. exposes
  1381. some
  1382. grass
  1383. so
  1384. let
  1385. me
  1386. show
  1387. you
  1388. what
  1389. this
  1390. looks
  1391. like
  1392. so
  1393. right
  1394. now
  1395. I
  1396. have
  1397. it
  1398. running
  1399. it's
  1400. it
  1401. it's
  1402. all
  1403. using
  1404. docker
  1405. so
  1406. I
  1407. started
  1408. it
  1409. with
  1410. docker
  1411. compose
  1412. so
  1413. this
  1414. is
  1415. a
  1416. dashboard
  1417. of
  1418. consul
  1419. and
  1420. you
  1421. can
  1422. see
  1423. all
  1424. the
  1425. services
  1426. and
  1427. they're
  1428. green
  1429. they're
  1430. all
  1431. healthy
  1432. and
  1433. this
  1434. is
  1435. the
  1436. front
  1437. end
  1438. with
  1439. as
  1440. you
  1441. can
  1442. see
  1443. random
  1444. random
  1445. data
  1446. since
  1447. I
  1448. don't
  1449. actually
  1450. have
  1451. the
  1452. smartthings
  1453. hub
  1454. here
  1455. but
  1456. the
  1457. nice
  1458. thing
  1459. is
  1460. I
  1461. can
  1462. stop
  1463. any
  1464. of
  1465. those
  1466. services
  1467. and
  1468. everything
  1469. that
  1470. depended
  1471. on
  1472. it
  1473. will
  1474. be
  1475. notified
  1476. immediately
  1477. so
  1478. I
  1479. can
  1480. stop
  1481. the
  1482. serializer
  1483. so
  1484. that'll
  1485. go
  1486. down
  1487. and
  1488. then
  1489. container
  1490. pilot
  1491. will
  1492. realize
  1493. that
  1494. that
  1495. service
  1496. is
  1497. not
  1498. healthy
  1499. and
  1500. stop
  1501. sending
  1502. a
  1503. heartbeat
  1504. to
  1505. console
  1506. so
  1507. if
  1508. I
  1509. go
  1510. back
  1511. to
  1512. console
  1513. refresh
  1514. and
  1515. see
  1516. the
  1517. serializer
  1518. is
  1519. no
  1520. longer
  1521. healthy
  1522. and
  1523. the
  1524. workers
  1525. actually
  1526. are
  1527. able
  1528. to
  1529. respond
  1530. to
  1531. that
  1532. and
  1533. not
  1534. even
  1535. try
  1536. to
  1537. make
  1538. a
  1539. request
  1540. because
  1541. they
  1542. know
  1543. there's
  1544. nothing
  1545. that
  1546. they
  1547. can
  1548. make
  1549. a
  1550. request
  1551. to
  1552. so
  1553. you
  1554. don't
  1555. have
  1556. that
  1557. failure
  1558. and
  1559. similarly
  1560. the
  1561. front-end
  1562. knows
  1563. that
  1564. the
  1565. serializer
  1566. is
  1567. down
  1568. so
  1569. it
  1570. stops
  1571. making
  1572. requests
  1573. back
  1574. to
  1575. that
  1576. but
  1577. if
  1578. you
  1579. bring
  1580. it
  1581. back
  1582. up
  1583. everything
  1584. starts
  1585. working
  1586. again
  1587. so
  1588. everything
  1589. well
  1590. the
  1591. the
  1592. time
  1593. series
  1594. data
  1595. is
  1596. not
  1597. the
  1598. easiest
  1599. to
  1600. work
  1601. with
  1602. there
  1603. so
  1604. everything
  1605. starts
  1606. working
  1607. again
  1608. and
  1609. responding
  1610. to
  1611. that
  1612. change
  1613. in
  1614. your
  1615. environment
  1616. so
  1617. you
  1618. have
  1619. a
  1620. lot
  1621. of
  1622. self
  1623. healing
  1624. qualities
  1625. built
  1626. into
  1627. this
  1628. so
  1629. let's
  1630. go
  1631. back
  1632. so
  1633. I
  1634. wanted
  1635. to
  1636. highlight
  1637. some
  1638. of
  1639. the
  1640. code
  1641. snippets
  1642. that
  1643. make
  1644. this
  1645. possible
  1646. this
  1647. is
  1648. from
  1649. the
  1650. serializer
  1651. and
  1652. I'm
  1653. using
  1654. the
  1655. piloted
  1656. module
  1657. which
  1658. just
  1659. keeps
  1660. a
  1661. local
  1662. cache
  1663. of
  1664. whatever
  1665. services
  1666. the
  1667. serializer
  1668. cares
  1669. about
  1670. in
  1671. this
  1672. case
  1673. so
  1674. give
  1675. me
  1676. a
  1677. healthy
  1678. address
  1679. for
  1680. in
  1681. Flex
  1682. DB
  1683. and
  1684. then
  1685. you
  1686. can
  1687. see
  1688. if
  1689. I
  1690. don't
  1691. have
  1692. one
  1693. I'm
  1694. just
  1695. going
  1696. to
  1697. use
  1698. an
  1699. in-memory
  1700. database
  1701. but
  1702. if
  1703. I
  1704. do
  1705. then
  1706. I'll
  1707. create
  1708. a
  1709. connection
  1710. so
  1711. that's
  1712. how
  1713. you
  1714. achieve
  1715. that
  1716. isolation
  1717. so
  1718. being
  1719. able
  1720. to
  1721. handle
  1722. the
  1723. case
  1724. where
  1725. you
  1726. don't
  1727. have
  1728. any
  1729. healthy
  1730. dependencies
  1731. and
  1732. to
  1733. respond
  1734. to
  1735. the
  1736. change
  1737. events
  1738. so
  1739. if
  1740. the
  1741. in
  1742. Flex
  1743. DB
  1744. comes
  1745. up
  1746. again
  1747. then
  1748. we'll
  1749. send
  1750. a
  1751. signal
  1752. to
  1753. the
  1754. process
  1755. and
  1756. piloted
  1757. will
  1758. handle
  1759. that
  1760. and
  1761. give
  1762. you
  1763. an
  1764. event
  1765. to
  1766. reload
  1767. and
  1768. reconnect
  1769. to
  1770. the
  1771. database
  1772. or
  1773. not
  1774. at
  1775. all
  1776. and
  1777. the
  1778. way
  1779. we
  1780. achieve
  1781. this
  1782. is
  1783. with
  1784. a
  1785. lot
  1786. of
  1787. help
  1788. from
  1789. container
  1790. pilot
  1791. which
  1792. runs
  1793. inside
  1794. the
  1795. container
  1796. and
  1797. it'll
  1798. register
  1799. each
  1800. of
  1801. the
  1802. services
  1803. for
  1804. you
  1805. with
  1806. console
  1807. it
  1808. takes
  1809. care
  1810. of
  1811. providing
  1812. some
  1813. lifecycle
  1814. hooks
  1815. and
  1816. gives
  1817. you
  1818. out-of-the-box
  1819. telemetry
  1820. reporting
  1821. with
  1822. Prometheus
  1823. and
  1824. we
  1825. started
  1826. it
  1827. as
  1828. an
  1829. init
  1830. process
  1831. because
  1832. it's
  1833. running
  1834. as
  1835. pit
  1836. one
  1837. so
  1838. it'll
  1839. actually
  1840. take
  1841. care
  1842. of
  1843. reaping
  1844. any
  1845. child
  1846. processes
  1847. or
  1848. child
  1849. zombie
  1850. processes
  1851. and
  1852. do
  1853. your
  1854. health
  1855. checks
  1856. for
  1857. you
  1858. register
  1859. your
  1860. service
  1861. as
  1862. I
  1863. said
  1864. and
  1865. and
  1866. watch
  1867. and
  1868. notify
  1869. you
  1870. if
  1871. anything
  1872. changes
  1873. and
  1874. you
  1875. can
  1876. find
  1877. the
  1878. source
  1879. code
  1880. for
  1881. it
  1882. it's
  1883. written
  1884. and
  1885. go
  1886. but
  1887. it's
  1888. on
  1889. our
  1890. joint
  1891. org
  1892. under
  1893. your
  1894. container
  1895. pilot
  1896. and
  1897. so
  1898. you
  1899. control
  1900. container
  1901. pilot
  1902. with
  1903. a
  1904. very
  1905. simple
  1906. configuration
  1907. file
  1908. we're
  1909. using
  1910. JSON
  1911. 5
  1912. now
  1913. it
  1914. also
  1915. supports
  1916. JSON
  1917. if
  1918. that's
  1919. what
  1920. you're
  1921. into
  1922. but
  1923. you
  1924. configure
  1925. it
  1926. with
  1927. what
  1928. you
  1929. care
  1930. about
  1931. so
  1932. the
  1933. watches
  1934. this
  1935. is
  1936. again
  1937. the
  1938. serializer
  1939. so
  1940. I'm
  1941. watching
  1942. for
  1943. any
  1944. changes
  1945. and
  1946. in
  1947. Flex
  1948. DB
  1949. so
  1950. if
  1951. more
  1952. instances
  1953. come
  1954. up
  1955. or
  1956. they
  1957. go
  1958. down
  1959. tell
  1960. me
  1961. about
  1962. it
  1963. and
  1964. we
  1965. can
  1966. figure
  1967. that
  1968. through
  1969. the
  1970. job
  1971. which
  1972. will
  1973. send
  1974. a
  1975. sick
  1976. up
  1977. signal
  1978. to
  1979. your
  1980. node
  1981. process
  1982. it
  1983. actually
  1984. doesn't
  1985. restart
  1986. the
  1987. process
  1988. because
  1989. we're
  1990. handling
  1991. that
  1992. signal
  1993. and
  1994. we're
  1995. refreshing
  1996. our
  1997. local
  1998. cache
  1999. of
  2000. the
  2001. healthy
  2002. addresses
  2003. and
  2004. to
  2005. configure
  2006. your
  2007. service
  2008. that
  2009. you
  2010. want
  2011. registered
  2012. you
  2013. just
  2014. need
  2015. to
  2016. tell
  2017. container
  2018. pilot
  2019. what
  2020. port
  2021. you're
  2022. gonna
  2023. listen
  2024. on
  2025. and
  2026. give
  2027. it
  2028. a
  2029. health
  2030. check
  2031. so
  2032. in
  2033. this
  2034. case
  2035. I
  2036. just
  2037. have
  2038. a
  2039. curl
  2040. command
  2041. that's
  2042. just
  2043. hitting
  2044. localhost
  2045. and
  2046. that'll
  2047. keep
  2048. sending
  2049. a
  2050. heartbeat
  2051. to
  2052. console
  2053. to
  2054. let
  2055. it
  2056. know
  2057. that
  2058. you're
  2059. still
  2060. healthy
  2061. or
  2062. not
  2063. and
  2064. so
  2065. because
  2066. of
  2067. this
  2068. we're
  2069. actually
  2070. able
  2071. to
  2072. do
  2073. some
  2074. of
  2075. the
  2076. patterns
  2077. that
  2078. you
  2079. would
  2080. have
  2081. would
  2082. also
  2083. see
  2084. in
  2085. micro-services
  2086. land
  2087. like
  2088. circuit
  2089. breakers
  2090. in
  2091. so
  2092. a
  2093. while
  2094. back
  2095. we
  2096. actually
  2097. built
  2098. into
  2099. happy
  2100. this
  2101. load
  2102. feature
  2103. so
  2104. it'll
  2105. respond
  2106. with
  2107. a
  2108. 503
  2109. if
  2110. your
  2111. process
  2112. is
  2113. under
  2114. too
  2115. much
  2116. load
  2117. which
  2118. you
  2119. define
  2120. what
  2121. that
  2122. means
  2123. can
  2124. be
  2125. memory
  2126. or
  2127. in
  2128. this
  2129. case
  2130. the
  2131. event
  2132. loop
  2133. delay
  2134. getting
  2135. too
  2136. bogged
  2137. down
  2138. and
  2139. so
  2140. in
  2141. this
  2142. case
  2143. if
  2144. your
  2145. process
  2146. gets
  2147. too
  2148. bogged
  2149. down
  2150. you're
  2151. not
  2152. healthy
  2153. anymore
  2154. and
  2155. then
  2156. all
  2157. of
  2158. the
  2159. other
  2160. micro
  2161. services
  2162. that
  2163. depended
  2164. on
  2165. you
  2166. are
  2167. notified
  2168. and
  2169. will
  2170. stop
  2171. calling
  2172. you
  2173. but
  2174. we
  2175. do
  2176. need
  2177. load
  2178. balancing
  2179. somewhere
  2180. since
  2181. you're
  2182. likely
  2183. to
  2184. have
  2185. more
  2186. than
  2187. one
  2188. service
  2189. that
  2190. you're
  2191. calling
  2192. write
  2193. more
  2194. instances
  2195. more
  2196. than
  2197. one
  2198. instance
  2199. of
  2200. that
  2201. service
  2202. that
  2203. you're
  2204. calling
  2205. so
  2206. piloted
  2207. out
  2208. of
  2209. the
  2210. box
  2211. we
  2212. just
  2213. do
  2214. round-robin
  2215. load
  2216. balancing
  2217. but
  2218. you
  2219. can
  2220. decide
  2221. however
  2222. you
  2223. want
  2224. to
  2225. load
  2226. balance
  2227. your
  2228. requests
  2229. on
  2230. the
  2231. client
  2232. it
  2233. could
  2234. be
  2235. random
  2236. it
  2237. could
  2238. be
  2239. round-robin
  2240. it's
  2241. really
  2242. up
  2243. to
  2244. you
  2245. so
  2246. I
  2247. want
  2248. to
  2249. also
  2250. highlight
  2251. how
  2252. cool
  2253. this
  2254. is
  2255. with
  2256. scaling
  2257. so
  2258. I
  2259. have
  2260. Nats
  2261. running
  2262. here
  2263. and
  2264. I
  2265. just
  2266. have
  2267. one
  2268. instance
  2269. of
  2270. it
  2271. and
  2272. Nats
  2273. operates
  2274. by
  2275. clustering
  2276. itself
  2277. together
  2278. like
  2279. you
  2280. would
  2281. typically
  2282. have
  2283. to
  2284. configure
  2285. what
  2286. you
  2287. know
  2288. instances
  2289. 2.22
  2290. cluster
  2291. but
  2292. because
  2293. we're
  2294. using
  2295. console
  2296. to
  2297. discover
  2298. other
  2299. Nats
  2300. instances
  2301. we
  2302. can
  2303. actually
  2304. cluster
  2305. automagically
  2306. I'll
  2307. say
  2308. so
  2309. I'll
  2310. just
  2311. use
  2312. the
  2313. scale
  2314. command
  2315. from
  2316. dr.
  2317. Campos
  2318. and
  2319. we
  2320. can
  2321. add
  2322. more
  2323. instances
  2324. this
  2325. of
  2326. the
  2327. serializer
  2328. we
  2329. can
  2330. also
  2331. add
  2332. more
  2333. instances
  2334. of
  2335. Nats
  2336. and
  2337. little
  2338. docker
  2339. will
  2340. spin
  2341. up
  2342. these
  2343. new
  2344. instances
  2345. for
  2346. us
  2347. and
  2348. as
  2349. they
  2350. come
  2351. online
  2352. they'll
  2353. be
  2354. registered
  2355. with
  2356. console
  2357. so
  2358. if
  2359. we
  2360. go
  2361. back
  2362. to
  2363. console
  2364. we
  2365. can
  2366. start
  2367. to
  2368. see
  2369. more
  2370. instances
  2371. coming
  2372. up
  2373. so
  2374. now
  2375. we
  2376. have
  2377. three
  2378. instances
  2379. of
  2380. Nats
  2381. running
  2382. and
  2383. Nats
  2384. is
  2385. also
  2386. we
  2387. have
  2388. a
  2389. container
  2390. pilot
  2391. solution
  2392. for
  2393. it
  2394. so
  2395. it'll
  2396. auto
  2397. cluster
  2398. itself
  2399. so
  2400. you
  2401. don't
  2402. have
  2403. to
  2404. do
  2405. any
  2406. configuration
  2407. it
  2408. just
  2409. knows
  2410. from
  2411. talking
  2412. to
  2413. console
  2414. that
  2415. there
  2416. are
  2417. other
  2418. Nats
  2419. instances
  2420. once
  2421. this
  2422. refreshes
  2423. so
  2424. it
  2425. clustered
  2426. itself
  2427. to
  2428. the
  2429. other
  2430. other
  2431. instances
  2432. there
  2433. and
  2434. then
  2435. again
  2436. you
  2437. could
  2438. scale
  2439. it
  2440. up
  2441. more
  2442. or
  2443. bring
  2444. it
  2445. down
  2446. it's
  2447. really
  2448. whatever
  2449. you
  2450. want
  2451. let's
  2452. see
  2453. so
  2454. even
  2455. though
  2456. I
  2457. was
  2458. kind
  2459. of
  2460. disparaging
  2461. load
  2462. balancers
  2463. between
  2464. your
  2465. services
  2466. they
  2467. still
  2468. definitely
  2469. have
  2470. a
  2471. purpose
  2472. more
  2473. at
  2474. the
  2475. edge
  2476. more
  2477. as
  2478. a
  2479. API
  2480. gateway
  2481. so
  2482. in
  2483. this
  2484. case
  2485. I
  2486. was
  2487. using
  2488. traffic
  2489. and
  2490. Express
  2491. gateway
  2492. there
  2493. are
  2494. lots
  2495. of
  2496. solutions
  2497. out
  2498. there
  2499. so
  2500. definitely
  2501. keep
  2502. that
  2503. in
  2504. mind
  2505. don't
  2506. entirely
  2507. expose
  2508. your
  2509. micro
  2510. services
  2511. directly
  2512. to
  2513. your
  2514. customers
  2515. so
  2516. the
  2517. last
  2518. point
  2519. I
  2520. want
  2521. to
  2522. make
  2523. is
  2524. about
  2525. telemetry
  2526. reporting
  2527. so
  2528. we
  2529. support
  2530. Prometheus
  2531. out
  2532. of
  2533. the
  2534. box
  2535. and
  2536. you
  2537. can
  2538. report
  2539. on
  2540. any
  2541. metric
  2542. you
  2543. care
  2544. about
  2545. again
  2546. I
  2547. like
  2548. the
  2549. event
  2550. loop
  2551. delay
  2552. so
  2553. in
  2554. this
  2555. example
  2556. I'm
  2557. just
  2558. configuring
  2559. container
  2560. pilot
  2561. to
  2562. report
  2563. on
  2564. the
  2565. event
  2566. loop
  2567. delay
  2568. for
  2569. me
  2570. and
  2571. then
  2572. Prometheus
  2573. will
  2574. recognize
  2575. that
  2576. and
  2577. and
  2578. console
  2579. and
  2580. go
  2581. out
  2582. and
  2583. start
  2584. pulling
  2585. in
  2586. the
  2587. data
  2588. from
  2589. every
  2590. instance
  2591. as
  2592. it
  2593. comes
  2594. up
  2595. so
  2596. this
  2597. is
  2598. what
  2599. you
  2600. would
  2601. see
  2602. in
  2603. Prometheus
  2604. to
  2605. see
  2606. the
  2607. event
  2608. loop
  2609. delay
  2610. so
  2611. if
  2612. you
  2613. want
  2614. to
  2615. learn
  2616. more
  2617. we
  2618. have
  2619. auto
  2620. pilot
  2621. pattern
  2622. do
  2623. I
  2624. have
  2625. links
  2626. again
  2627. if
  2628. you
  2629. go
  2630. to
  2631. a
  2632. node
  2633. summit
  2634. off
  2635. of
  2636. my
  2637. website
  2638. and
  2639. then
  2640. there's
  2641. some
  2642. other
  2643. links
  2644. there
  2645. for
  2646. you
  2647. as
  2648. well
  2649. so
  2650. thank
  2651. you
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement