text
stringlengths
0
1.17k
[793.84 --> 800.58] and so we were looking at uh at you know two three four times multipliers in terms of volume
[800.58 --> 806.74] but more than anything we really didn't know how well the upstream services are going to perform
[806.74 --> 813.32] so if you think about it node sits between the clients and the uh and the java services and
[813.32 --> 819.44] because node is doing such a great job managing the income track the incoming traffic it's such a great
[819.44 --> 827.66] uh little executable for managing sockets it's basically acting as a queue so load balancer is
[827.66 --> 832.72] basically sending traffic to the node processes and then they are trying to proxy it over to java and
[832.72 --> 838.16] if java is behind and starting to get slow it doesn't really add much load on the node process in terms
[838.16 --> 842.04] of cpu because it's just because it's a non-blocking system so it doesn't do anything it's just sit there
[842.04 --> 847.76] waiting for socket events and no socket events are coming back but what is happening is that we are
[847.76 --> 852.42] growing in memory because all we were keeping we keep holding more and more and more sessions in
[852.42 --> 859.94] memory until the java stuff is ready and in that environment basically node becomes a queue and if
[859.94 --> 865.16] java gets very very slow then notice you know the queue gets very very big until at some point it blows
[865.16 --> 870.48] up so we didn't really know what to expect in terms of how big is this queue going to be how how well is
[870.48 --> 876.82] the memory going to perform so we we basically dumped a lot of extra capacity we ended up i think with
[876.82 --> 883.34] about six times more capacity than we actually needed um which really contributed to like the
[883.34 --> 889.42] completely boring yeah exactly performance so this was then a major success right for you and your team
[889.42 --> 899.06] this this was huge i think um i think we kind of proved the entire stack but also like my the quote
[899.06 --> 904.50] i've been using uh privately in conversation with the node core team and and you know a few other
[904.50 --> 912.32] companies like joint and uh um voxer um i kept saying like i don't want to be the uh i don't
[912.32 --> 916.08] want to be what twitter was for rails i don't want to be the the you know rails doesn't know
[916.08 --> 922.62] yeah of node um because even though like you know it was largely bullshit at the time um
[922.62 --> 929.36] it it did cause quite a significant damage to to rails adoption um you know once once twitter was
[929.36 --> 933.82] having problems a lot of people uh there was like this this backlash and people were going back to
[933.82 --> 941.98] php because you know facebook was on php and that was clearly much better yeah um so so i i was like
[941.98 --> 946.64] i'm not going to be that guy like like i'm not going to be the number one you know headline on hacker
[946.64 --> 955.24] news saying you know no doesn't scale uh just ask walmart so i was i was really freaking out about that
[955.24 --> 961.22] and and that was kind of that was like the back of my mind um as we were approaching this yeah so we
[961.22 --> 967.10] kind of threw more capacity at it we were like watching it um like everybody on the node core team
[967.10 --> 971.08] was like following it throughout the night like all waiting for like anything if anything goes wrong
[971.08 --> 977.22] to jump on irse with us and like help us fix it live um it was really like you know it it meant a lot
[977.22 --> 981.16] to the community as a whole yeah it seemed like it i mean that's really the way i took it because
[981.16 --> 988.44] we tweeted said we tweeted uh that night uh follow um node bf on twitter and lots of retweets came
[988.44 --> 993.76] from that and i think your tweet alone got 82 favorites and 157 retweets and it just seemed like a lot of
[993.76 --> 998.24] people were just like watching real time and a lot of people who were involved in node just kind of like
[998.24 --> 1004.58] you know behind the scenes cheering to make sure that you know everything had gone successfully for you
[1004.58 --> 1009.66] yeah my uh my follower count on twitter jumped by like a thousand for the night
[1009.66 --> 1016.14] um it's crazy it was it was uh it was quite funny but it's a you know it's like you said it's big for
[1016.14 --> 1020.56] the community right i mean people that like node they want to see node succeed and so it's not just
[1020.56 --> 1025.96] big for you and your team because you're proving an emerging technology to a to a you know a very large
[1025.96 --> 1031.12] company but it is it's it's it's big for the whole community because like you said if if something
[1031.12 --> 1035.94] would have fallen flat on its face whether it was your fault or you know an inherent problem with node
[1035.94 --> 1041.28] then you're right the the rumors would have been node can't scale and i mean you still hear that
[1041.28 --> 1045.24] every once in a while when people are talking about rails you know just when they haven't you know
[1045.24 --> 1049.30] been maybe not in the community for the last couple years but you'll still you know every once in a
[1049.30 --> 1053.46] hear somebody say rails can't scale and you know that that kind of sticks with you so you're right it's
[1053.46 --> 1057.80] a it's a good thing for the whole community not just the the walmart node branch you know
[1057.80 --> 1066.72] yeah this this was a big deal and it also uh at node summit i gave a talk but basically my plan for
[1066.72 --> 1072.30] node summit was to give a talk about black friday of course there was nothing to talk about so i
[1072.30 --> 1079.00] basically gave a talk about how everything went wrong all the way until black friday and uh we only got
[1079.00 --> 1088.76] the the fix for the for the infamous memory leak in um the week off like we actually that that was we
[1088.76 --> 1094.78] and we couldn't even verify because we're doing daily uh daily releases so we we never actually got to
[1094.78 --> 1099.54] observe the server over you know over like 48 hours to see that the memory leak was actually fixed
[1099.54 --> 1107.78] so it was all very theoretical and we so that was part of the the thing is that if the memory leak was
[1107.78 --> 1114.58] still going on uh it required us to restart our servers every seven days and we were expecting you
[1114.58 --> 1120.68] know up to 10x yes traffic and well that means we can have to restart the servers more than once a day
[1120.68 --> 1126.94] yeah and on black friday you don't really want to touch your servers right um so so it was all very
[1126.94 --> 1132.06] suspenseful but it was kind of like uh edge of your seat suspenseful but boredom so did you have somebody
[1132.06 --> 1136.02] like working on that memory leak all the time trying to find it or what happened with that
[1136.02 --> 1143.92] um so we found a memory leak uh well we we saw the pattern of the memory leak back in uh april already
[1143.92 --> 1152.08] and then by june it was i i was convinced the memory leak um and it was uh it was one of those things
[1152.08 --> 1156.98] where like i i i argue with everybody including my own team that it is a memory leak and they're all
[1156.98 --> 1162.34] like no it must be something else uh and i said no it's an it's a node memory leak and they're like no
[1162.34 --> 1165.50] this it can't be no then really because if somebody else would report it right like other people are
[1165.50 --> 1171.84] using node in production and they're not seeing any of that behavior and so we end up spending quite
[1171.84 --> 1176.94] a lot of effort uh putting quite a lot of monitoring into the system where i was basically spending
[1176.94 --> 1181.92] three months trying to find correlation between the memory leak when memory was was spiking to when
[1181.92 --> 1188.40] something else was going on so we added monitors for uh client disconnects and response times and
[1188.40 --> 1196.26] uh concurrent connections and just connections per uh per second and like really like we have we we build
[1196.26 --> 1202.38] in so much monitoring into it so we can start comparing it and nothing correlated just absolutely
[1202.38 --> 1208.62] nothing we knew the more traffic we get overall the more leak we get but it's not the leaking is not
[1208.62 --> 1214.32] happening when the traffic is coming in it's just that there's a correlation between the overall daily
[1214.32 --> 1221.28] pattern and at some point i found a few clues that i had some ideas and i said okay we're going to
[1221.28 --> 1225.78] make a configuration change that is going to double the amount of http client calls that we're making
[1225.78 --> 1231.64] and uh and i said and watch we'll do that and the memory leak will double itself and people were like
[1231.64 --> 1236.20] kept saying like no no it's not gonna happen and of course memory leak doubled itself
[1236.20 --> 1245.16] uh which helped us you know zoom zoom into the exact um spot where we're we're leaking and i was able
[1245.16 --> 1250.38] to isolate that and then i wrote a little program that that showed it but it took about 12 hours of it
[1250.38 --> 1257.82] to run to even show you a slight leak and it was all from what closing file descriptors no it ended up
[1257.82 --> 1264.80] being a missing uh handle scope in the c++ side of node in what it was one it was one line missing
[1264.80 --> 1273.60] a node uh in one function um it was basically two c++ words that was the bug and it caused a four in some
[1273.60 --> 1281.22] cases it caused a four bytes leak per http request yeah so that takes a little while to add up but that
[1281.22 --> 1290.18] definitely ends up uh yeah and so and at the time we were leaking about um eight eight megs a day
[1290.18 --> 1297.78] so so we we got it really really low by mitigating it in other ways but um couldn't really solve it and
[1297.78 --> 1303.66] then uh uh um tj fontaine from the node core team um was able to uh he spent like three weeks on it
[1303.66 --> 1311.26] um we took some crazy stuff and there's a there's a great blog post on the um on the joint uh blog
[1311.26 --> 1320.10] uh detailing exactly uh uh what tj uh uh used and and it's kind of like uh a little bit like uh
[1320.10 --> 1325.48] black magic so that's interesting the blog post though let me ask you what was that experience
[1325.48 --> 1329.94] like going back and forth with the the node core team and and you know trying to prove this and
[1329.94 --> 1335.86] how receptive were they to you like you know pointing this stuff out so when we first reported it uh
[1335.86 --> 1342.88] back in like june or july it was the uh people have been quite dismissive um where basically the
[1342.88 --> 1347.76] the theory was like there is no way we have such a gigantic memory leak and you're the only one seeing
[1347.76 --> 1353.18] it um but when at the end when i was able to actually come and say hey here's a little bit of
[1353.18 --> 1358.20] node code and if you run it it will show you the leak uh and then of course they ran and they're like
[1358.20 --> 1361.68] no we're not seeing any leak and i said like just just leave it alone for 12 hours and come back to
[1361.68 --> 1365.66] it tomorrow and they did and they opened it up and it's like no it still doesn't look like a leak
[1365.66 --> 1371.46] it's like oh go ahead and plot your trend line yeah on that on that chart and then they did that
[1371.46 --> 1375.18] and i was like oh yeah you know what it looks like there's something going on there and then as they
[1375.18 --> 1381.06] edit more instrumentation they can actually start seeing um what was actually happening is uh
[1381.06 --> 1389.68] uh v8 was building a gigantic array of undefined which is where the four bytes came from basically it
[1389.68 --> 1395.52] was pointing to the canonical undefined reference within the v8 uh it was just building a gigantic