English feliratok

← Scaling Settings - Developing Scalable Apps with Java

Beágyazókód kérése
6 Languages

Showing Revision 5 created 05/25/2016 by Udacity Robot.

  1. So now when we have written all this code,
  2. let's look at how to scale your application, using
  3. modules. Modules are a serious heavy-duty function within App
  4. Engine and they allow you to partition your code, have
  5. better control over scalability, and do version control and
  6. online upgrades. For simplicity, we did not use modules when
  7. building Conference Central, but it is something we strongly
  8. suggest you start exploring on your own. By looking at
  9. the online documentation. All right, let's get started. When
  10. you create an App Engine application using modules, it will
  11. conceptually be structured like a tree. At the very
  12. top, we have the root, which is your application, and
  13. your application is made up of a number of
  14. modules, in this example two. A module groups three concepts.
  15. Code related to the module. The instance class that
  16. should be used to execute the code, this is the
  17. speed of the CPU, and the amount of memory
  18. that should be used. The scalability parameters including the number
  19. of instances to start and their life cycle. So
  20. a module groups code to be executed, the performance resources
  21. and the scalability and instance life cycle you want to
  22. have. Each module can then have a number of different
  23. versions associated with it. A version is essentially a
  24. version of your code being maintained in the module. So,
  25. after you have deployed your application into production you
  26. can deploy new versions of your code and you
  27. can have multiple versions running in parallel, and gradually
  28. migrate traffic from the old version to the new. This
  29. capability allows you to do version upgrades without having
  30. to bring down your application. Something that is extremely difficult
  31. to do without App Engine. And finally, there are
  32. instances. An instance is what actually executes the application code.
  33. And if you want to scale your application, App Engine
  34. can fire up more instances to manage the additional load.
  35. And since the instance class and the number of instances
  36. define the performance and scalability of a module. The capacity of
  37. your application depends on the instances class and the number
  38. of instances you run. This is configured on the module
  39. level, and that is exactly what we will look at
  40. now. How to configure a module. Lets start looking at two
  41. scaling options for modules. Manual Scaling and Automatic Scaling.
  42. These specify different scale up and scale down characteristics of
  43. instances. Manual scaling allows you to create instances that are
  44. always up and running and that never terminates. Because of
  45. this, they don't have the ten minute execution limit
  46. with they process tasks or cron jobs. Since they are
  47. always up and running, they can work for any amount
  48. of time. And that means that they are great to
  49. use if you have long running background tasks or
  50. cron jobs. The only thing you need to configure for
  51. manual scaling is the number of instances you want
  52. the module to start. That's manual scaling. Let's now talk
  53. about automatic scaling. Automatic scaling is the option that
  54. allows App Engine to automatically scale your application up and
  55. down depending on the load. The first two options
  56. you can specify for automatic scaling is the minimum and
  57. maximum number of idle instances you want. What does
  58. this mean? Why would you want to have idle instances?
  59. Well, instances have a startup time and if you
  60. don't want your users to wait for the response while
  61. your application needs to scale up by starting new
  62. instances, and it could be good to have idle instances
  63. available if your application needs to scale up. So your
  64. users don't have to wait for more instances to start.
  65. Let's now look at latency. Where you can specify
  66. the minimum and maximum pending latency allowed for requests. These
  67. parameters work as follows. So let's say a request comes
  68. into your application right here, and there's no instance available
  69. to process it. Then it is put in a wait
  70. queue. App Engine now has a decision to make. When
  71. to scale up your application using more instances. Well, to
  72. begin with, it will wait for some time to see
  73. if any of the existing instances become available to
  74. process their request. This is called a minimum pending
  75. latency, if this time passes, App Engine is considering
  76. starting a new instance to manage the request. And if
  77. the next pending latency time expires, then a new
  78. instance would be started for sure to manage the load.
  79. This is how App Engine performs a scale up
  80. of your application. Rather than specifying a number for these
  81. four parameters, you can all set them to automatic.
  82. In such case, App Engine will set them according
  83. to the dynamic analysis it performs. Finally, both manual
  84. and automatic scaling have a common configuration element. Which is
  85. the Instance Class. The instance class specifies the speed
  86. of the CPU and the amount of memory to
  87. use for each of the instances started. Check out
  88. the developer documentation for more details on the options available.
  89. As you probably see by now, modules is
  90. heavy-duty stuff. And in addition to the scaling options
  91. we looked at, it also has versions that
  92. we briefly touched on. Versions allow you to perform
  93. online upgrades on part of your system without
  94. any service disruption. Without App Engine, doing automatic scaling
  95. and dynamic upgrades are extremely difficult problems to solve.
  96. So make sure that you use this great functionality.