Home > Uncategorized > Why you can’t always just throw more hardware at it

Why you can’t always just throw more hardware at it

February 6, 2009 Leave a comment Go to comments

A long time ago, people used to worry about the efficiencies of software they used to write. Then came a time when processors just kept getting faster every month the pace wouldn’t slow down even after crossing the 500MHz mark. Somewhere around this time, people started writing exceptionally bloated software and the bloat started to grow at a phenomenal pace. Then came the new catch phase hardware is cheap, we can throw more hardware at it. And in one magic swoop, all bloatware became perfectly acceptable since the bloat now seemed to be affordable. And this was precisely the point wherein most people forgot their CS fundamentals. If you have done a course on CPU scheduling, you would know these metrics:

  1. CPU utilisation
  2. Throughput
  3. Turnaround time
  4. Waiting time
  5. Response time

I will take up web application space as an example in the remainder of the discussions since it has a fairly large development community and also because it is littered with bloatware + hardware is cheap mentality. In web applications, the consumer is usually worried about response times and turnaround times. Let us say there is solution A wherein it takes a full second for the server to process a single web request and solution B that takes 50 milliseconds to process a single web request. A very misplaced number that people chase is requests/second and this is solved using the now infamous throw more hardware approach. Focus on throughput works in businesses when your consumers have nowhere else to go and your notion of increasing business is by increasing volumes. You don’t hear people switching banks because of how fast (or slow) their websites load and the reason is that main product offering is banking service and not a website i.e. you would worry more about interest rates rather than website response times. Businesses whose primary offering is the website itself cannot take such liberties.

Turnaround time

Turnaround time is the total time taken to service a request. So, if you have a slow running web page, you can keep adding more hardware to take on more volume (assuming the solution can be scaled out infinitely) but the experience of each individual user is not going to improve. Also, real world experience suggests that left to itself, things start to slow down as you scale out. A knee jerk fix is to do things in parallel and use threads. That also usually doesn’t get you too far thanks to what a certain Amdahl had to say. This is where all those classes on algorithms, architecture and the abstinence from bloatwares begin to make some difference.

Response time

Response time is what is usually called as time to first byte in the internet world. In trying to solve the turnaround time problem, one of the speedup areas that people work on is minimizing the context switches from user space to kernel space. Zero copy is an example of one such problem. The most common example however happens to be buffered files (or streams if you are from the Java world). Some people (and their software creations) take this to the extreme and try and send out the entire HTTP response in one shot hoping to minimize the number of system calls needed to get the job done. It turns out that this makes for a worse user experience. Put it another way, it is better off to start sending something to the user after 200 milliseconds (ms) and finish it in the next 4 seconds rather than start sending something 2 seconds after the request was issued and get done in the next 500 ms.  In fact this is a harder problem to solve for two reasons:

  • Left to itself, most web servers aren’t eager to push back smaller chunks of data (easier problem to solve)
  • Dynamic pages, especially the ones generated MVC frameworks do not make the response available to the web server until they have fully constructed the response body. Some of these solutions offer no straight forward way to push out data in parts while others have explicit mechanisms of achieving this effect.

For those of you who are still wondering why something that puts on extra load on the server and takes longer to finish is considered better by the user, there are two reasons:

  • Psychological: Giving the user an early indication of some progress creatives some incentive for the user to wait rather than sending no information. Even getting the status bar to say recieving from … as opposed to sending request to … makes a difference.
  • Pipeline effect: An average web page has references to various resources (images, external css files, etc. etc.) that are needed to completely render a page. It turns out that most browsers can initiate the retrieval of those resources before the page loads up completely. Pushing out a partial response early on gives the browsers a chance to get started with other things early on. So while the additional flushes done on the server side might have slowed down the turnaround time for basic page transmission, the overall turnaround time as seen by the user can still drop with this technique.

Throughput

Since throughput signifies the total amount of work that gets done in a unit of time, it turns out that throwing more hardware can sort of solve this problem. As I had mentioned earlier, if you solution scales infinitely, then the hardware addition technique works. The reason why things do not scale infinitely are:

  • There ends up being some components that are hard to scale infinitely such as the top level load balancer and the pipes that it is connected to
  • Amdahl’s law

One of the most common fixes that is a borderline superstition is to run more threads. In a CPU bound world, having any more threads of execution than the number of compute unit slows things down. In a NUMA based world, certain workloads can be detrimental even when the number of threads matches the number of compute unit available. However, for workloads that are I/O bound, threads do help as long as the different threads are not contending for the same underlying I/O resource. The one exception is rotating storage media where the amortized performance increases as concurrent requests increase but only up to a certain point.

In effect, the reasons for throughput not increasing just by increasing either the concurrency levels of task execution or by throwing in more hardware beyond a certain point is very real.

Closing remarks

We are now in an age where people not only believe that hardware is cheap but also in cloud computing that promises provisioning of infinite hardware (i.e. more than you can afford). The thing to remember is that you might extend the life of a given solution for quite sometime by throwing in hardware (at diminishing rate of returns) but if you are chasing response times, you will have to constantly improvise on your design as opposed relying on hardware.

  1. February 8, 2010 10:23 am | #1

    The “throw more hardware” issue is slowly becoming less of a problem as server farms are finally being called expensive (imagine that) and need to get lean.
    Also, it seems we are reaching a sort of inflection point between “enough hardware” and “too much information still waiting to be processed”.

    Case in point, Facebook’s recent launch of HipHop for PHP that allwas for faster and nimbler code.

    Of course, it does not solve the basic problem of bloatware that you described, but I’m hoping it is a start.

    Like everything else, this problem and it’s solution seem cyclical

  2. mayur
    February 10, 2010 10:24 pm | #2

    Nice.

  1. January 15th, 2012 at 16:13 | #1
  2. January 15th, 2012 at 22:52 | #2
  3. January 16th, 2012 at 02:04 | #3
  4. January 16th, 2012 at 04:45 | #4
  5. January 17th, 2012 at 01:47 | #5
  6. January 17th, 2012 at 06:04 | #6
  7. January 17th, 2012 at 14:55 | #7
  8. January 18th, 2012 at 00:18 | #8
  9. January 18th, 2012 at 01:37 | #9
  10. January 18th, 2012 at 01:46 | #10
  11. January 18th, 2012 at 07:39 | #11
  12. January 18th, 2012 at 18:01 | #12
  13. January 18th, 2012 at 18:15 | #13
  14. January 18th, 2012 at 21:05 | #14
  15. January 20th, 2012 at 00:31 | #15
  16. January 20th, 2012 at 16:52 | #16
  17. January 20th, 2012 at 19:31 | #17
  18. January 21st, 2012 at 07:08 | #18
  19. January 22nd, 2012 at 18:51 | #19
  20. January 22nd, 2012 at 19:24 | #20
  21. January 23rd, 2012 at 08:51 | #21
  22. January 23rd, 2012 at 23:52 | #22
  23. January 24th, 2012 at 11:44 | #23
  24. January 24th, 2012 at 21:49 | #24
  25. January 24th, 2012 at 23:06 | #25
  26. January 24th, 2012 at 23:30 | #26
  27. January 25th, 2012 at 20:46 | #27
  28. January 25th, 2012 at 21:16 | #28
  29. January 25th, 2012 at 21:24 | #29
  30. January 25th, 2012 at 23:07 | #30
  31. January 25th, 2012 at 23:12 | #31
  32. January 25th, 2012 at 23:37 | #32
  33. January 25th, 2012 at 23:46 | #33
  34. January 26th, 2012 at 00:10 | #34
  35. January 26th, 2012 at 00:27 | #35
  36. January 26th, 2012 at 05:10 | #36
  37. January 26th, 2012 at 08:43 | #37
  38. January 26th, 2012 at 09:47 | #38
  39. January 26th, 2012 at 11:29 | #39
  40. January 26th, 2012 at 14:55 | #40
  41. January 27th, 2012 at 03:40 | #41
  42. January 27th, 2012 at 04:44 | #42
  43. January 27th, 2012 at 05:13 | #43
  44. January 27th, 2012 at 06:29 | #44
  45. January 27th, 2012 at 06:57 | #45
  46. January 27th, 2012 at 09:10 | #46
  47. January 27th, 2012 at 09:33 | #47
  48. January 27th, 2012 at 12:37 | #48
  49. January 27th, 2012 at 15:34 | #49
  50. January 27th, 2012 at 16:17 | #50
  51. January 27th, 2012 at 17:24 | #51
  52. January 27th, 2012 at 17:46 | #52
  53. January 27th, 2012 at 18:15 | #53
  54. January 27th, 2012 at 20:01 | #54
  55. January 27th, 2012 at 21:59 | #55
  56. January 27th, 2012 at 23:19 | #56
  57. January 27th, 2012 at 23:51 | #57
  58. January 28th, 2012 at 01:46 | #58
  59. January 28th, 2012 at 03:32 | #59
  60. January 28th, 2012 at 03:35 | #60
  61. January 28th, 2012 at 05:11 | #61
  62. January 28th, 2012 at 14:09 | #62
  63. January 28th, 2012 at 14:40 | #63
  64. January 28th, 2012 at 15:21 | #64
  65. January 28th, 2012 at 17:04 | #65
  66. January 28th, 2012 at 18:50 | #66
  67. January 28th, 2012 at 19:37 | #67
  68. January 28th, 2012 at 21:15 | #68
  69. January 28th, 2012 at 22:23 | #69
  70. January 28th, 2012 at 22:48 | #70
  71. January 28th, 2012 at 23:18 | #71
  72. January 28th, 2012 at 23:47 | #72
  73. January 29th, 2012 at 01:59 | #73
  74. January 29th, 2012 at 03:03 | #74
  75. January 29th, 2012 at 03:10 | #75
  76. January 29th, 2012 at 03:30 | #76
  77. January 29th, 2012 at 03:41 | #77
  78. January 29th, 2012 at 04:14 | #78
  79. January 29th, 2012 at 04:45 | #79
  80. January 29th, 2012 at 05:11 | #80
  81. January 29th, 2012 at 06:26 | #81
  82. January 29th, 2012 at 19:20 | #82
  83. January 29th, 2012 at 19:56 | #83
  84. January 29th, 2012 at 20:23 | #84
  85. January 29th, 2012 at 21:11 | #85
  86. January 29th, 2012 at 21:38 | #86
  87. January 29th, 2012 at 22:55 | #87
  88. January 29th, 2012 at 23:02 | #88
  89. January 29th, 2012 at 23:12 | #89
  90. January 29th, 2012 at 23:58 | #90
  91. January 30th, 2012 at 00:36 | #91
  92. January 30th, 2012 at 01:20 | #92
  93. January 30th, 2012 at 01:52 | #93
  94. January 30th, 2012 at 02:25 | #94
  95. January 30th, 2012 at 03:12 | #95
  96. January 30th, 2012 at 03:36 | #96
  97. January 30th, 2012 at 04:18 | #97
  98. January 30th, 2012 at 05:03 | #98
  99. January 30th, 2012 at 05:35 | #99
  100. January 30th, 2012 at 06:11 | #100
  101. January 30th, 2012 at 06:30 | #101
  102. January 30th, 2012 at 12:43 | #102
  103. January 30th, 2012 at 13:24 | #103
  104. January 30th, 2012 at 14:31 | #104
  105. January 30th, 2012 at 15:16 | #105
  106. January 30th, 2012 at 15:51 | #106
  107. January 30th, 2012 at 15:53 | #107
  108. January 30th, 2012 at 16:51 | #108
  109. January 30th, 2012 at 17:42 | #109
  110. January 30th, 2012 at 18:56 | #110
  111. January 30th, 2012 at 19:44 | #111
  112. January 30th, 2012 at 23:26 | #112
  113. January 30th, 2012 at 23:46 | #113
  114. January 31st, 2012 at 00:06 | #114
  115. January 31st, 2012 at 02:26 | #115
  116. January 31st, 2012 at 04:12 | #116
  117. January 31st, 2012 at 04:34 | #117
  118. January 31st, 2012 at 05:56 | #118
  119. January 31st, 2012 at 09:35 | #119
  120. January 31st, 2012 at 13:11 | #120
  121. January 31st, 2012 at 13:41 | #121
  122. January 31st, 2012 at 15:33 | #122
  123. January 31st, 2012 at 16:19 | #123
  124. January 31st, 2012 at 16:50 | #124
  125. January 31st, 2012 at 17:13 | #125
  126. January 31st, 2012 at 18:21 | #126
  127. January 31st, 2012 at 19:45 | #127
  128. January 31st, 2012 at 20:10 | #128
  129. January 31st, 2012 at 20:56 | #129
  130. February 1st, 2012 at 02:14 | #130
  131. February 1st, 2012 at 03:29 | #131
  132. February 1st, 2012 at 04:05 | #132
  133. February 1st, 2012 at 12:36 | #133
  134. February 1st, 2012 at 13:44 | #134
  135. February 1st, 2012 at 15:06 | #135
  136. February 1st, 2012 at 16:06 | #136
  137. February 1st, 2012 at 16:38 | #137
  138. February 1st, 2012 at 18:26 | #138
  139. February 1st, 2012 at 20:25 | #139
  140. February 1st, 2012 at 20:47 | #140
  141. February 1st, 2012 at 21:00 | #141
  142. February 2nd, 2012 at 02:00 | #142
  143. February 2nd, 2012 at 02:32 | #143
  144. February 2nd, 2012 at 03:04 | #144
  145. February 2nd, 2012 at 03:43 | #145
  146. February 2nd, 2012 at 04:29 | #146
  147. February 2nd, 2012 at 05:09 | #147
  148. February 2nd, 2012 at 05:44 | #148
  149. February 2nd, 2012 at 06:10 | #149
  150. February 2nd, 2012 at 12:40 | #150
  151. February 2nd, 2012 at 12:50 | #151
  152. February 2nd, 2012 at 13:29 | #152
  153. February 2nd, 2012 at 13:48 | #153
  154. February 2nd, 2012 at 14:02 | #154
  155. February 2nd, 2012 at 14:12 | #155
  156. February 2nd, 2012 at 15:24 | #156
  157. February 2nd, 2012 at 15:42 | #157
  158. February 2nd, 2012 at 15:46 | #158
  159. February 2nd, 2012 at 16:42 | #159
  160. February 2nd, 2012 at 20:05 | #160
  161. February 3rd, 2012 at 04:40 | #161
  162. February 3rd, 2012 at 13:20 | #162
  163. February 3rd, 2012 at 13:38 | #163
  164. February 3rd, 2012 at 13:49 | #164
  165. February 3rd, 2012 at 17:45 | #165
  166. February 3rd, 2012 at 20:34 | #166
  167. February 3rd, 2012 at 23:12 | #167
  168. February 4th, 2012 at 08:42 | #168
  169. February 4th, 2012 at 12:19 | #169
  170. February 5th, 2012 at 02:20 | #170
  171. February 5th, 2012 at 06:43 | #171
  172. February 5th, 2012 at 08:56 | #172
  173. February 5th, 2012 at 09:43 | #173
  174. February 5th, 2012 at 19:12 | #174
  175. February 5th, 2012 at 20:09 | #175
  176. February 6th, 2012 at 07:46 | #176
  177. February 6th, 2012 at 08:25 | #177