YouTube2Text

How to Scale Your App to Global Levels - System Design — Transcript

by Caleb Curry · 5,196 words · 750 segments · language en · Watch on YouTube

Full transcript

  1. 0:00this video we are going to be talking
  2. 0:02about how we can scale an app to go
  3. 0:04across the entire world so this is going
  4. 0:07to build on some of the principles we
  5. 0:09talked about with horizontal scaling
  6. 0:11when you take a server and to grow you
  7. 0:16will add multiple servers working
  8. 0:19together as a single unit this is the
  9. 0:22idea of horizontal scaling but what we
  10. 0:24didn't talk about is where are these
  11. 0:27servers located or where is the entire
  12. 0:31collection located are they very close
  13. 0:33together or are they spread out across
  14. 0:35the world so let's first talk about when
  15. 0:37you horizontally scale how close will
  16. 0:40those servers be located to one another
  17. 0:42now we're going to talk about a few
  18. 0:43different options here but first you
  19. 0:45might want to check out the previous
  20. 0:46lesson which talked about horizontal and
  21. 0:48vertical scaling that'll give you the
  22. 0:49foundational information as well as two
  23. 0:51other resources the first being the
  24. 0:53backend engineering mind map and this is
  25. 0:56a comprehensive overview of everything
  26. 0:58you might need to be familiar with if
  27. 1:00you want to become a backend software
  28. 1:01engineer another resource is I have a
  29. 1:03mentorship program if you want guidance
  30. 1:06in learning these things and succeeding
  31. 1:07at technical interviews check that out
  32. 1:09I'll have links for those below so if we
  33. 1:11grow to multiple servers these could be
  34. 1:14within the same data center or they
  35. 1:17could be in different data centers in
  36. 1:18the same region so same data center or
  37. 1:21same region diff Data Center and what
  38. 1:25exactly is a region well that's kind of
  39. 1:27vague but let's just say it's you know a
  40. 1:29a certain amount of distance you might
  41. 1:31have a data center in a different region
  42. 1:34but we'll say it's still within the same
  43. 1:37country so for example within the US you
  44. 1:39might split the us up into multiple
  45. 1:41regions and you might have data centers
  46. 1:43in different regions but they're all
  47. 1:45within the United States and then lastly
  48. 1:47we could have servers in completely
  49. 1:49different countries and those could be
  50. 1:52across different continents even now
  51. 1:55this is the stage you want to get to if
  52. 1:57you really want to bring your app Global
  53. 2:01and that is built off of the assumption
  54. 2:03that the Earth is truly a globe but
  55. 2:05we're not going to get into that in this
  56. 2:07video but just think about it this way
  57. 2:09right like if the Earth was a globe how
  58. 2:13would flat shoes work wouldn't you have
  59. 2:14to have shoes that were like slightly
  60. 2:16curved to match the curvature of the
  61. 2:19Earth come on guys all you globiste
  62. 2:24theorists why am I even getting into
  63. 2:26this so if you're a True Believer in the
  64. 2:28globe Earth theory then I'm going to
  65. 2:30need an answer for that question
  66. 2:32otherwise we're going to get back to it
  67. 2:34now I'm going to change this to
  68. 2:35continents because that's where the
  69. 2:36biggest difference comes up as there are
  70. 2:38regions that are in different countries
  71. 2:41but still within the same continent so
  72. 2:42you might group those regions as North
  73. 2:44America regions for example and we're
  74. 2:47going to get into some of that in a few
  75. 2:48moments so we're basically looking at it
  76. 2:51from closest together to most spread out
  77. 2:54for this one they are in different
  78. 2:56regions but they're still within the
  79. 2:58same region set most most likely the
  80. 3:00same continent and then lastly
  81. 3:02completely different continents so let's
  82. 3:04go through each one of these the first
  83. 3:06one being the same data
  84. 3:11center now you can think of a data
  85. 3:13center just as a building or potentially
  86. 3:15multiple buildings but all one location
  87. 3:18so there might be a company or a cloud
  88. 3:20provider that hosts a bunch of stuff
  89. 3:22from one data center in one location so
  90. 3:26if you have multiple servers let's say
  91. 3:28we have two servers
  92. 3:30and they're in the same data center it
  93. 3:32might be the case that these are
  94. 3:33physically located right next to each
  95. 3:35other and you can imagine this improves
  96. 3:37the application somewhat because if one
  97. 3:40of the servers breaks the other one is
  98. 3:42still there to take traffic so this
  99. 3:44helps the service become highly
  100. 3:47available and it helps with the
  101. 3:50scalability because you have two servers
  102. 3:53instead of just
  103. 3:54one this does not help with
  104. 3:57latency because these servers are pretty
  105. 3:59much right next to each other it doesn't
  106. 4:01matter if I make a request to this one
  107. 4:04or this one it's going to take roughly
  108. 4:06the same amount of time so it does not
  109. 4:08really impact the performance of the
  110. 4:10application for any individual request
  111. 4:13it does help with the overall
  112. 4:14performance because it allows us to have
  113. 4:17more users cool so that is all within
  114. 4:20the same data center now let's talk
  115. 4:21about within the same region but
  116. 4:23different data centers so for us to
  117. 4:26understand things being in the same
  118. 4:28region we should first understand what a
  119. 4:31region is and it's a little vague and it
  120. 4:34probably varies from cloud provider to
  121. 4:36cloud provider we're going to take a
  122. 4:38look at AWS as an example here but the
  123. 4:40idea is probably very similar for other
  124. 4:42services out there so within AWS you
  125. 4:45will have a collection of different
  126. 4:47regions based on continent so for
  127. 4:50example in North America there are
  128. 4:53currently eight regions and I think a
  129. 4:56ninth one is coming soon and that's
  130. 4:58based on the time this recording so
  131. 5:01these numbers might change in the future
  132. 5:03but there's eight different regions in
  133. 5:05North America right now you'll probably
  134. 5:07want to pick a region that's fairly
  135. 5:08close to the users of your application
  136. 5:11these are all given some name such as us
  137. 5:16East
  138. 5:191 or Us East 2 there's Us West one US
  139. 5:25West 2 so for example if you're going to
  140. 5:27be serving a lot of users in California
  141. 5:29you probably want to go for one of the
  142. 5:31West regions compared to the east
  143. 5:34regions now these are different
  144. 5:38regions but for this level of scale
  145. 5:40we're talking about different data
  146. 5:42centers within the same region so if you
  147. 5:45just select one of
  148. 5:47these obviously we're going to go with
  149. 5:49us East to Ohio represent let's go all
  150. 5:52right so within here we're going to have
  151. 5:54multiple data centers so there may be
  152. 5:57many Data Centers inside of us East too
  153. 6:00but we're going to split those up so
  154. 6:02we'll have different availability zones
  155. 6:05which are logically separated data
  156. 6:07centers So within a region there are
  157. 6:10multiple data centers so these logical
  158. 6:12groupings the availability zones as AWS
  159. 6:15calls them will have names like us East
  160. 6:222A Us East
  161. 6:272B Us East
  162. 6:312 C so in this scenario if we want to go
  163. 6:33within the same region but different
  164. 6:36data centers we would split up those
  165. 6:38servers into two different availability
  166. 6:43zones so now we have a server here and
  167. 6:46we have a server here the different
  168. 6:49availability zones within the same
  169. 6:51region are physically separated but set
  170. 6:54up in such a way that they can
  171. 6:56communicate between each other very
  172. 6:58efficiently so you can imagine we have a
  173. 7:00group of data centers over here a group
  174. 7:02of data centers over here and then a
  175. 7:03connection between them for data
  176. 7:05transfer there's a good chance they're
  177. 7:07both not going to be impacted directly
  178. 7:09from a power outage but they're still
  179. 7:11within a fairly close distance and
  180. 7:13they're set up to communicate quickly so
  181. 7:16you are a bit more safe from issues that
  182. 7:18might impact an entire data center or
  183. 7:20availability zone so these guys are set
  184. 7:22up to be able to communicate
  185. 7:26efficiently but they're physically
  186. 7:28separated so they're in the same
  187. 7:31region diff availability zone so this is
  188. 7:35going to improve the high availability
  189. 7:39so it's going to be more available than
  190. 7:41if they're in the same data center
  191. 7:43because we are removing a single point
  192. 7:45of failure physically having just a
  193. 7:47single location for the servers so now
  194. 7:49if there's a power outage there's a
  195. 7:51chance the service stays available it
  196. 7:53will still help with scalability because
  197. 7:55we have two servers so that hasn't
  198. 7:58changed either in terms of latency it's
  199. 8:01probably not going to make a major
  200. 8:02difference because the servers are so
  201. 8:05close together that it's not that big of
  202. 8:08a deal like they're both within Ohio so
  203. 8:11if you're making a request from
  204. 8:12California doesn't really matter if you
  205. 8:14hit this server or This Server because
  206. 8:16they're so close together so the biggest
  207. 8:18benefit in this step is that you're
  208. 8:19protecting yourself against issues that
  209. 8:21might impact a complete availability
  210. 8:24Zone possibly leaving your service
  211. 8:26completely unavailable if both of your
  212. 8:28servers
  213. 8:32possibly leaving your service completely
  214. 8:33unavailable if they are within the same
  215. 8:36data center or availability zone so the
  216. 8:38major benefit you get going to this step
  217. 8:40is protecting against issues that could
  218. 8:42impact an entire availability Zone if
  219. 8:45they were both in the same location both
  220. 8:48of the servers then you could
  221. 8:50potentially go completely unavailable if
  222. 8:52something happened to that location so
  223. 8:55that is the major benefit you get from
  224. 8:57having things within the same region but
  225. 8:59splitting it out to two different
  226. 9:01availability zones this is a fairly
  227. 9:03simple step so it's not going to add a
  228. 9:05lot of complexity to your architecture
  229. 9:07so I would probably recommend doing this
  230. 9:09for protecting your high availability
  231. 9:11all right so we go beyond just a single
  232. 9:14region we're now ready to go to multiple
  233. 9:16regions so we could have servers in
  234. 9:18different regions so in this scenario
  235. 9:20you can imagine having a server on the
  236. 9:22west coast of the US and on the east
  237. 9:24coast of the us and we somehow need to
  238. 9:27get these things to work together in
  239. 9:28this scenario you might need to do a
  240. 9:30little bit more setup than the previous
  241. 9:31scenario because we want these servers
  242. 9:34to work together but there's a good
  243. 9:36chance we're not just going to evenly
  244. 9:38load balance across these two regions
  245. 9:41let's see how good I can draw the US
  246. 9:59pretty flipping good if you ask me so
  247. 10:03let's just say you have a server here
  248. 10:06and a server over here and you have
  249. 10:07people making requests from all over and
  250. 10:11you know maybe even outside of the US so
  251. 10:13these are different clients making
  252. 10:16requests to servers now we probably want
  253. 10:19to keep in mind their location when we
  254. 10:22direct them to a certain server so it
  255. 10:25probably makes sense for this one to be
  256. 10:27directed to This Server same here this
  257. 10:30one maybe here and this one may be here
  258. 10:32so we don't just want to blindly split
  259. 10:36the traffic across the two servers
  260. 10:40because that gets rid of the major
  261. 10:42benefit of going multi- region which is
  262. 10:46that we can make servers closer to the
  263. 10:48clients making requests so instead of
  264. 10:51just having a load balancer that
  265. 10:52surrounds both of these you'll probably
  266. 10:54use geolocation routing so this will be
  267. 10:57at the DNS level directing based off of
  268. 11:01the location of the request so where
  269. 11:03does load balancing come in then most
  270. 11:05likely you will individually scale these
  271. 11:08units based off of the amount of traffic
  272. 11:12in that General region so let's just say
  273. 11:14in theory this is getting
  274. 11:1675% of the traffic to your API in this
  275. 11:20case and this one's getting 25% this
  276. 11:24means we could give a lot more Computing
  277. 11:26resources to this unit over here and
  278. 11:28less to this one over here when it comes
  279. 11:30to load balancing instead of just
  280. 11:32thinking of this as a single computer
  281. 11:34you can think of it as a single unit or
  282. 11:37a single service logically so this might
  283. 11:41actually consist of multiple computers
  284. 11:44so you can imagine it to look something
  285. 11:45like this where we actually have three
  286. 11:47servers in this region this one might
  287. 11:50consist of just two servers they can be
  288. 11:52different so the load balancing is most
  289. 11:54likely going to
  290. 11:56happen at this level
  291. 12:01so we split the load between these
  292. 12:03individual servers and we split the load
  293. 12:05across these servers and another thing
  294. 12:08to keep in mind is that for each one of
  295. 12:10these I'm just going to draw some arrows
  296. 12:11here because I'm running out of space
  297. 12:13these could be in different availability
  298. 12:17zones So within the same region but in
  299. 12:21different data centers so that goes off
  300. 12:23of what we talked about in the previous
  301. 12:25section same idea here these could be in
  302. 12:27different availability zones
  303. 12:30so I'm going to erase this and do a
  304. 12:31quick summary of this so take a mental
  305. 12:33snapshot remember how beautiful my us
  306. 12:36drawing is so let's make a little
  307. 12:38diagram showing the flow of a request we
  308. 12:41have the client making a request I'm
  309. 12:43imagining this to be a web page
  310. 12:45requesting data from an API this is
  311. 12:48going to use some kind of geolocation
  312. 12:52based
  313. 12:54DNS and this will be the way that we
  314. 12:58know which
  315. 12:59section to direct to and this is the
  316. 13:01step where the client is given one of
  317. 13:04the regions maybe that's West Coast
  318. 13:06maybe that's East Coast based on the
  319. 13:07location of the client so you would set
  320. 13:10this up at the DNS level so for example
  321. 13:12in Route 53 and there are various
  322. 13:14techniques to doing that maybe that's
  323. 13:15something we can get into in more detail
  324. 13:17in the future but for now we're just
  325. 13:18going to kind of assume this level works
  326. 13:21we need some way to direct to the
  327. 13:24appropriate region this will be
  328. 13:25especially important once we move to
  329. 13:27multiple continents because we don't
  330. 13:29want to be sending people from Europe
  331. 13:31all the way to the US or from us all the
  332. 13:33way to Europe because of that latency so
  333. 13:35this is an important step we're just
  334. 13:37going to kind of gloss over for right
  335. 13:38now assume that works so this is going
  336. 13:40to direct it in this case one of two
  337. 13:43different ways we have region
  338. 13:46one and then we have region two you can
  339. 13:48think of this step kind of as a load
  340. 13:50balancer for cross region but within a
  341. 13:53single region this is where we'll
  342. 13:55actually have a load balancer same thing
  343. 13:58over here
  344. 14:00most likely if we have multiple servers
  345. 14:03in one region so that's going to be a
  346. 14:05single end point that is hit when the
  347. 14:08client is routed to that region and this
  348. 14:11is going to route to let's say three
  349. 14:14different servers on this side and just
  350. 14:16to show that it doesn't have to be the
  351. 14:17same all of the time we could say we
  352. 14:19have two servers over on this side we
  353. 14:23can scale them independently so you can
  354. 14:26horizontally scale independently meaning
  355. 14:28adding more servers on one side than the
  356. 14:30other and you could vertically scale
  357. 14:32independently as well so you could
  358. 14:34increase the size of one individual
  359. 14:36server if you needed for some reason
  360. 14:37which probably don't need to do if
  361. 14:39you're going to be horizontally scaling
  362. 14:41but just so you are aware that that's
  363. 14:43possible so this is one way to do it but
  364. 14:45if you also include the split across
  365. 14:48multiple availability zones it's going
  366. 14:50to look a little bit different so it
  367. 14:51might look like this where we have
  368. 14:53availability Zone a availability Zone B
  369. 14:56so it may look like this where this
  370. 14:59availability Zone has two servers and
  371. 15:01this availability Zone has one server
  372. 15:04same idea over here so we'll have
  373. 15:06availability Zone
  374. 15:07a and availability Zone
  375. 15:12B and this one will have a
  376. 15:16server and this one will have a
  377. 15:18server so this is what it may look like
  378. 15:22so one request might be routed like this
  379. 15:25we go from the client with DNS it routes
  380. 15:28us to region one ultimately giving us
  381. 15:30this load
  382. 15:31balancer choosing to direct us to this
  383. 15:35availability Zone and ultimately to This
  384. 15:38Server the question now is what happens
  385. 15:40if we have some other services that this
  386. 15:43service needs to interact with most
  387. 15:45common one that I would think of here
  388. 15:46would be a database so let's say we have
  389. 15:48a database here and this API server
  390. 15:50needs to read data from the database so
  391. 15:53it's going to make a request to the
  392. 15:55database and every server might need to
  393. 15:57do that so if we're over here we might
  394. 16:00also need to make a request from that
  395. 16:02database so we basically did all this
  396. 16:04Fancy Pants routing but then we
  397. 16:06ultimately have to make a request to
  398. 16:08another server which this line here
  399. 16:11might introduce a substantial amount of
  400. 16:13latency if we route somebody through to
  401. 16:15a West Coast server and then that West
  402. 16:18Coast server has to make a request back
  403. 16:20to an East Coast database then it
  404. 16:22defeats the purpose of sending them to
  405. 16:23the West Coast server in the first place
  406. 16:25we could just have everything over in
  407. 16:26the east coast and we wouldn't have to
  408. 16:28worry about all this multiple region
  409. 16:29garbage we could just keep it simple so
  410. 16:31all that to say is as you spread things
  411. 16:33out it introduces new complexities
  412. 16:35because now you have to think about all
  413. 16:37the other services that this service
  414. 16:39interacts with let's say this request is
  415. 16:42100 milliseconds and this one is 200
  416. 16:45milliseconds now let's say we sent that
  417. 16:47same client over to the east coast and
  418. 16:50through this process it takes 20000
  419. 16:54milliseconds but then the database
  420. 16:56request because it's closer to the
  421. 16:58server to
  422. 16:59100
  423. 17:00milliseconds the total time here is the
  424. 17:03same so if you look at these these add
  425. 17:04up to
  426. 17:06300 and these add up to
  427. 17:10300 so it wouldn't really matter if we
  428. 17:13directed the person on the west coast to
  429. 17:15the West Coast server or to the east
  430. 17:17coast server because it's just going to
  431. 17:19adjust the numbers between the API layer
  432. 17:21and the database layer ultimately giving
  433. 17:23us roughly the same value now I know
  434. 17:25there's a lot going on here and I'm
  435. 17:26almost done so we'll clear this off in a
  436. 17:28second but I wanted to mention two
  437. 17:29potential fixes for this that we're
  438. 17:31really going to explore in much more
  439. 17:33detail in upcoming lessons one way to
  440. 17:36address this latency concern is to have
  441. 17:38a multi- primary database or multimaster
  442. 17:41multi- database where not only do you
  443. 17:44have the database over here but it's
  444. 17:47connected to another instance over here
  445. 17:50this could potentially be much closer to
  446. 17:53This Server so instead of directing the
  447. 17:55traffic up that way we could direct it
  448. 17:56up this way reducing that lat from 200
  449. 18:00to let's say 100 improving the overall
  450. 18:04performance for that request that's one
  451. 18:06potential fix so I'll just write these
  452. 18:08up here so having multiple right nodes
  453. 18:10in your database now the next possible
  454. 18:13solution or at least Improvement here
  455. 18:15would be a little bit simpler especially
  456. 18:17if you're working with like post grass
  457. 18:19or other relational databases you could
  458. 18:21just have read replicas so in the case
  459. 18:23of read replicas you'll still have this
  460. 18:24database instance here but it will be
  461. 18:26limited to just reading wow this is
  462. 18:29getting insane but that's going to at
  463. 18:32least improve much of the performance of
  464. 18:35the app it's often the case that we do
  465. 18:37majority reading so so in the case of
  466. 18:39social media most of the time you're
  467. 18:40reading the feed you're not writing
  468. 18:42posts as much as you're reading posts so
  469. 18:44that's one way we can improve it as well
  470. 18:46and it's simpler than having multiple
  471. 18:48right nodes but we are going to again
  472. 18:50get into databases in much detail in one
  473. 18:53of the upcoming lessons I've been saying
  474. 18:55that for multiple lessons now but we're
  475. 18:57building and building and building we're
  476. 18:59almost there so keep that in mind we're
  477. 19:01going to address this in a future video
  478. 19:04in much more detail a third one which
  479. 19:06I'm not going to draw much for would be
  480. 19:08cashing so specifically
  481. 19:12the I said specifically like I had
  482. 19:14something specific in mind that my brain
  483. 19:15was like duh so with caching there's a
  484. 19:19bunch of different caching levels we
  485. 19:20could talk about we've talked about them
  486. 19:22some when we were talking while scaling
  487. 19:23an app to millions of users but here are
  488. 19:25some examples we could completely cach
  489. 19:28pages so we don't even have to make a
  490. 19:30request to the API we could cache
  491. 19:32certain things in the database in a
  492. 19:34local cache which is much closer to the
  493. 19:38server so in the same region in that
  494. 19:40situation instead of reading from the
  495. 19:41database you would read from the cache
  496. 19:45and then you would only need to hit the
  497. 19:46database if you didn't find the
  498. 19:47information you were looking for all
  499. 19:48right I'm going to erase this before I
  500. 19:50throw up and we're going to do a quick
  501. 19:51quick summary of what we just talked
  502. 19:53about so we just talked about splitting
  503. 19:54an app across multiple regions it
  504. 19:57definitely increases the complexity as
  505. 19:59you probably can tell from our previous
  506. 20:00diagram but it's still a way that you
  507. 20:03can improve latency this will also help
  508. 20:05us with high
  509. 20:07availability now the chances of
  510. 20:10something going wrong that affects
  511. 20:12multiple regions man that's bad so we
  512. 20:15definitely have higher availability and
  513. 20:18we can definitely scale the app more so
  514. 20:21scalability now let's talk about a few
  515. 20:23concerns the complexity which includes
  516. 20:26setting this up as well as communication
  517. 20:29between services that are in different
  518. 20:31regions such as if you have a database
  519. 20:33you have to access that's in a different
  520. 20:34region always draw upward it drives me
  521. 20:37crazy and potentially this will be
  522. 20:39higher costs so if you're in a scenario
  523. 20:42where you're ever transferring data
  524. 20:44between regions you might be charged for
  525. 20:46the movement of that data you can do
  526. 20:48additional research on that if that's
  527. 20:50something you might be doing but the
  528. 20:52idea is that as you spread things out
  529. 20:55there is a cost to moving things that
  530. 20:57you'll need to account for for and
  531. 20:59here's just something to consider which
  532. 21:01is this still might not be Global the
  533. 21:03ideas we talked about are pretty much
  534. 21:05going to be the same when we're working
  535. 21:06with regions that are outside of North
  536. 21:09America for example but if you start
  537. 21:11running servers from other countries or
  538. 21:13other continents there are a few other
  539. 21:15concerns you need to be aware of and
  540. 21:16that's what we're going to talk about
  541. 21:17next so we've talked about three
  542. 21:19different deployment options when it
  543. 21:20comes to bringing your app global the
  544. 21:23first being just everything within the
  545. 21:25same data center pretty limiting the
  546. 21:26next splitting across Data Center but
  547. 21:28within the same region then splitting
  548. 21:30things up to different regions and now
  549. 21:32we're going to talk about splitting
  550. 21:34things up into different continents now
  551. 21:37the regions are often grouped by
  552. 21:39continent but some of the concerns I
  553. 21:41want to talk about are going to be at a
  554. 21:43country level potentially so
  555. 21:45specifically this has to do with user
  556. 21:47information privacy and different rules
  557. 21:50for different countries so if we want to
  558. 21:53take an app global we have to worry
  559. 21:55about local concerns
  560. 21:59so whatever the localization
  561. 22:00requirements might
  562. 22:04be and this is going to depend a lot on
  563. 22:08the type of app you're building and I'm
  564. 22:10definitely not going to cover this topic
  565. 22:12adequately you will need to do as much
  566. 22:15research as you can if you're going to
  567. 22:17be storing data in different countries
  568. 22:20and you're going to be building an app
  569. 22:22that works across multiple countries
  570. 22:23where you have servers running in
  571. 22:25different countries working with two
  572. 22:26regions in the US is probably going to
  573. 22:28be treated the same legally but if you
  574. 22:30have a region in Europe that's going to
  575. 22:33be different than in the US I'll go
  576. 22:35through a couple quick examples in the
  577. 22:37US there's something known as cui which
  578. 22:40is information that's not classified but
  579. 22:42still sensitive that's probably
  580. 22:44something you don't want to be storing
  581. 22:46in servers and other continents I don't
  582. 22:49know the ins and outs of the laws for
  583. 22:51that and that's just one example of data
  584. 22:53but if you were working with classified
  585. 22:55information for example then yeah that's
  586. 22:57probably even going to be more strict on
  587. 22:59where it can be stored I think different
  588. 23:01Cloud providers might even have
  589. 23:03specialized instances for certain types
  590. 23:05of data So within the US you might be
  591. 23:08able to get a server that has some
  592. 23:11additional restrictions but I think AWS
  593. 23:14has some gov Cloud instances or
  594. 23:16something that might be more compliant
  595. 23:19for certain rules or laws so you can
  596. 23:22look into that it's going to be pretty
  597. 23:24similar for European data so gdpr or
  598. 23:28health records of people in Europe that
  599. 23:30might be something that you have to keep
  600. 23:32physically located in Europe again I
  601. 23:34know I've said this but I'm not an
  602. 23:35expert on any of this stuff I just
  603. 23:37wanted to bring it up to make you aware
  604. 23:39of it I feel like if I left this out it
  605. 23:40wouldn't be complete but it's something
  606. 23:42that's really specific for the type of
  607. 23:44application you're building and what
  608. 23:46countries you're going to be servicing
  609. 23:48you can imagine if a large percentage of
  610. 23:49your user base is from say China maybe
  611. 23:52there are some certain laws you have to
  612. 23:53adhere to depending on what type of data
  613. 23:56you're storing so the two biggest things
  614. 23:58to to think about when it comes to going
  615. 24:00to different continents the first are
  616. 24:02the potential latency improvements
  617. 24:04especially if all of the services that
  618. 24:07your request is going to hit are in that
  619. 24:09region so if you're using some kind of
  620. 24:11global database like Dynamo DB Global
  621. 24:13tables where you can write and read from
  622. 24:16multiple regions that's going to
  623. 24:18drastically improve the performance
  624. 24:20because the latency is going to go down
  625. 24:22a lot consider making a request over the
  626. 24:24internet from Europe to the US that's
  627. 24:26going to take a lot longer than if you
  628. 24:28could keep everything just in Europe for
  629. 24:30a European user and then the other thing
  630. 24:31to concern yourself with are any local
  631. 24:33laws for where you're storing data or
  632. 24:36the users that are accessing your
  633. 24:37services now there's a concept multi-
  634. 24:39region failover so let's say you had two
  635. 24:42regions and these were pretty far apart
  636. 24:45because you're working on improving
  637. 24:46latency for users but say something goes
  638. 24:49wrong this region is not working you can
  639. 24:53direct everybody down to the other
  640. 24:56region so not just people who are local
  641. 24:58but people that are far away this really
  642. 25:00does go back to the geodns stuff that we
  643. 25:02were talking about but just wanted to
  644. 25:04let you know that it's not something
  645. 25:06where one Region's going to go down and
  646. 25:0850% of your users can't use your app if
  647. 25:11there are no concerns about localized
  648. 25:13laws or whatever there's a good chance
  649. 25:14you can just direct traffic over to
  650. 25:17another region and that can often be set
  651. 25:20up to happen automatically so you have a
  652. 25:21very resilient service now I wanted to
  653. 25:24talk briefly about CDN again this might
  654. 25:27be some review from the the previous
  655. 25:28videos but I wanted to talk about them
  656. 25:31within this context as they can help us
  657. 25:34achieve similar results to routing based
  658. 25:37off of geolocation so this is basically
  659. 25:40going to put your content on a bunch of
  660. 25:46edge
  661. 25:48servers across the
  662. 25:50world so this goes back to what we were
  663. 25:53talking about with caching this is
  664. 25:54another form where if somebody makes a
  665. 25:56request from right there they will
  666. 25:58probably hit that edge server whereas if
  667. 26:01somebody makes a request from right here
  668. 26:04they might hit that edge server so it's
  669. 26:07kind of like a little hack so that you
  670. 26:09can get some of those benefits of being
  671. 26:11Global without having to have such a
  672. 26:14complex architecture now typically these
  673. 26:16are for static files so HTML CSS
  674. 26:20JavaScript images videos those kinds of
  675. 26:23things that's where CDN shine however
  676. 26:25because of the focus on the static
  677. 26:28content it might be more limited than
  678. 26:30having a server in different locations
  679. 26:34that's cdns in general but there may be
  680. 26:36some variations so potentially you could
  681. 26:39cash responses from apis that would also
  682. 26:42improve the app performance then it's
  683. 26:44kind of like you have a distributed
  684. 26:46server but really it's just a snapshot
  685. 26:49of a very recent response so if you have
  686. 26:52data that you're retrieving that doesn't
  687. 26:54update very frequently you could
  688. 26:56potentially cash that response making
  689. 26:58things faster across the world or
  690. 27:01something that is a little bit different
  691. 27:03than this traditional CDN idea are Edge
  692. 27:07workers so you could imagine each one of
  693. 27:09these being a
  694. 27:12server that can do
  695. 27:14computation so if there's a way we can
  696. 27:17basically distribute our API layer
  697. 27:20across many Edge servers in this
  698. 27:23scenario we could have a true backend
  699. 27:25that's distributed across the world if
  700. 27:27you're interested in learning more about
  701. 27:29this idea you can research cloudflare
  702. 27:31workers most likely adding a CDN is
  703. 27:33going to be a step you would do fairly
  704. 27:35early on in your app deployment process
  705. 27:38I would probably do this almost first
  706. 27:39thing because it's going to immediately
  707. 27:41improve the performance for users across
  708. 27:43the world and often there are other
  709. 27:45benefits packaged with it such as
  710. 27:46security and dos protection and SEO
  711. 27:49benefits cool so that's a summary of the
  712. 27:51CDN lay perhaps that's something we'll
  713. 27:53do a dedicated video to All the ins and
  714. 27:56outs of CDN and how they work what you
  715. 27:57can can cash what you can't cash how
  716. 27:59caching Works maybe that's interesting
  717. 28:01if so let me know and maybe we'll do a
  718. 28:03video on it now when it comes to scaling
  719. 28:05databases that's what the next section
  720. 28:08of videos is really going to be about so
  721. 28:10we'll talk about some general database
  722. 28:12Concepts so the cap theorum and other
  723. 28:14things like that and that's going to
  724. 28:16build a foundation for us to understand
  725. 28:18the different types of databases that
  726. 28:20exist when you might want to choose one
  727. 28:22over the other and all of the ins and
  728. 28:25outs when it comes to scaling the app to
  729. 28:27support more and more users so I would
  730. 28:29encourage you to leave this video with
  731. 28:31the intention of following up with the
  732. 28:33next video so you can continue your
  733. 28:35studies there's a lot of information but
  734. 28:37it's fun it's cool we get to draw on a
  735. 28:39chalkboard in what other scenarios do
  736. 28:41you get to draw cute boxes and arrows
  737. 28:43and call it studying so let's stick with
  738. 28:46it stay tuned for the next lesson we
  739. 28:48will talk about database stuff and I'm
  740. 28:51sure it'll be a great time thank you so
  741. 28:53much for watching this video as a
  742. 28:54reminder I'll have links to resources
  743. 28:56down below which will include the
  744. 28:57backend engine mind map and the link to
  745. 29:00the mentorship program if you want to
  746. 29:02take it up a notch when it comes to your
  747. 29:04career and your ability to pick up this
  748. 29:06information thank you so much for
  749. 29:07watching and I'll see you in the next
  750. 29:09ones

About this transcript

This page contains the full transcript of How to Scale Your App to Global Levels - System Design by Caleb Curry, generated from the public captions YouTube serves with the video. The transcript has 5,196 words across 750 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.