summaryrefslogblamecommitdiffstats
path: root/archives/extend/2013-April/000097.html
blob: 0fce37e14ca3ea7d51bcef4da6c62d4bfc7905fb (plain) (tree)























































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
 <HEAD>
   <TITLE> [99s-extend] cowboy and chromium
   </TITLE>
   <LINK REL="Index" HREF="index.html" >
   <LINK REL="made" HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20cowboy%20and%20chromium&In-Reply-To=%3CB51E1290-B953-4A81-9B1F-BA9229E65AF1%40gmail.com%3E">
   <META NAME="robots" CONTENT="index,nofollow">
   <style type="text/css">
       pre {
           white-space: pre-wrap;       /* css-2.1, curent FF, Opera, Safari */
           }
   </style>
   <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
   <LINK REL="Previous"  HREF="000096.html">
   <LINK REL="Next"  HREF="000098.html">
 </HEAD>
 <BODY BGCOLOR="#ffffff">
   <H1>[99s-extend] cowboy and chromium</H1>
    <B>Sasa Juric</B> 
    <A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20cowboy%20and%20chromium&In-Reply-To=%3CB51E1290-B953-4A81-9B1F-BA9229E65AF1%40gmail.com%3E"
       TITLE="[99s-extend] cowboy and chromium">sasa.juric at gmail.com
       </A><BR>
    <I>Wed Apr 10 17:11:57 CEST 2013</I>
    <P><UL>
        <LI>Previous message: <A HREF="000096.html">[99s-extend] cowboy and chromium
</A></li>
        <LI>Next message: <A HREF="000098.html">[99s-extend] Distributed model?
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#97">[ date ]</a>
              <a href="thread.html#97">[ thread ]</a>
              <a href="subject.html#97">[ subject ]</a>
              <a href="author.html#97">[ author ]</a>
         </LI>
       </UL>
    <HR>  
<!--beginarticle-->
<PRE>Thanks!

On Apr 10, 2013, at 5:07 PM, Lo&#239;c Hoguin wrote:

&gt;<i> It's running from the moment Cowboy starts expecting a new request up to the moment it got the request in full (excluding the body), then it's reset for the next request.
</I>&gt;<i> 
</I>&gt;<i> On 04/10/2013 05:05 PM, Sasa Juric wrote:
</I>&gt;&gt;<i> Ok, just to make sure I understand:
</I>&gt;&gt;<i> When I serve a request, and the connection is not closed due to keep-alive, will this timeout also apply?
</I>&gt;&gt;<i> 
</I>&gt;&gt;<i> 
</I>&gt;&gt;<i> On Apr 10, 2013, at 5:01 PM, Lo&#239;c Hoguin wrote:
</I>&gt;&gt;<i> 
</I>&gt;&gt;&gt;<i> Means it's not a read timeout, but a timeout for the whole request up to and excluding the body (so an intentionally slow client will get disconnected at 5s).
</I>&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;<i> On 04/10/2013 04:56 PM, Sasa Juric wrote:
</I>&gt;&gt;&gt;&gt;<i> Thanks!
</I>&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;<i> I was looking at the option, but was confused by description which states:
</I>&gt;&gt;&gt;&gt;<i> Time in milliseconds a client has to send the full request line and headers.
</I>&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;<i> I'll give it a try and see how it works.
</I>&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;<i> Best regards,
</I>&gt;&gt;&gt;&gt;<i> Sasa
</I>&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;<i> On Apr 10, 2013, at 4:51 PM, Lo&#239;c Hoguin wrote:
</I>&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;<i> 'timeout' protocol option, in milliseconds.
</I>&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;<i> On 04/10/2013 04:50 PM, Sasa Juric wrote:
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> I agree with you. In addition, I can't reproduce without the proxy, which confirms the suspicion.
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> Looking at the code of mochiweb which I was using, the connection timeout is set to 5 minutes.
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> The other factor, which I can confirm is that when the server terminates the connection, the proxy doesn't forward this to the client. Hence, the client and proxy probably &quot;think&quot; that connection is still active, and try to reuse it, but this doesn't work until timeout.
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> Other browsers probably can gracefully handle this situation, but for some reason chromium is stuck to 60 seconds and after retry it presumably opens new connection and succeeds.
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> Question: can I configure keep-alive timeout in Cowboy?
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> On Apr 10, 2013, at 4:41 PM, Lo&#239;c Hoguin wrote:
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> On 04/10/2013 02:00 PM, Sasa Juric wrote:
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Hi,
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> I have recently in my production system replaced mochiweb with cowboy. The server generally works fine, except for a bizarre behavior which I cannot quite explain, so I post here, hoping to get some pointers.
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> After replacing mochiweb with cowboy, I noticed that in chromium (other major browsers work fine) often (but not always) a request lasts a little more than a minute. Further inspection in <A HREF="chrome://net-internals">chrome://net-internals</A> showed that browser tries to send a request, times out after 60 sec, retries and then succeeds immediately. The key point is that it doesn't happen always. First couple of requests work fine, then all of a sudden one doesn't work. At the same time requests from other browsers (including chrome) on the same machine work fine.
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> If I revert to mochiweb, the problem disappears. Other than web server related code, everything else is the same: the rest of my code, the server setup etc... In addition, I return same responses and headers in both versions.
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> After many attempts and failures, I might have worked around the issue. Namely, I included &lt;&lt;&quot;connection&quot;&gt;&gt;, &lt;&lt;&quot;close&quot;&gt;&gt; in all responses. After this change, it seems that long requests are not occurring. In any case, I can't reproduce it anymore, whereas before the change I could have reproduce it easily.
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> However, I'm not sure if I have really resolved the issue, I'm also not happy with connection closes since it degrades performance. And finally, I'm not sure if I quite understand the problem.
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> The only theory I have is that due to keep-alive, chromium holds the connection, while cowboy closes it (I read somewhere that hardcoded timeout is 5 seconds, right?). In this case it might happen that chromium sends a request to a non existing socket and then hangs for a minute, waiting for the response which never arrives.
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> This might further be amplified by the fact that in production, between browser and cowboy, there is a proxy/load balancer, so maybe load balancer still holds the connection despite the fact that server had closed it.
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> This is the only theory I currently have, and I would like to hear if you guys have some other idea or any kind of helpful pointer?
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Haven't seen this happen on plain Cowboy. The proxy might be the culprit. See if you can reproduce without the proxy.
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> --
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Lo&#239;c Hoguin
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Erlang Cowboy
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Nine Nines
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> <A HREF="http://ninenines.eu">http://ninenines.eu</A>
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;&gt;&gt;<i> --
</I>&gt;&gt;&gt;&gt;&gt;<i> Lo&#239;c Hoguin
</I>&gt;&gt;&gt;&gt;&gt;<i> Erlang Cowboy
</I>&gt;&gt;&gt;&gt;&gt;<i> Nine Nines
</I>&gt;&gt;&gt;&gt;&gt;<i> <A HREF="http://ninenines.eu">http://ninenines.eu</A>
</I>&gt;&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;<i> 
</I>&gt;&gt;&gt;<i> --
</I>&gt;&gt;&gt;<i> Lo&#239;c Hoguin
</I>&gt;&gt;&gt;<i> Erlang Cowboy
</I>&gt;&gt;&gt;<i> Nine Nines
</I>&gt;&gt;&gt;<i> <A HREF="http://ninenines.eu">http://ninenines.eu</A>
</I>&gt;&gt;<i> 
</I>&gt;<i> 
</I>&gt;<i> 
</I>&gt;<i> -- 
</I>&gt;<i> Lo&#239;c Hoguin
</I>&gt;<i> Erlang Cowboy
</I>&gt;<i> Nine Nines
</I>&gt;<i> <A HREF="http://ninenines.eu">http://ninenines.eu</A>
</I>

</PRE>

<!--endarticle-->
    <HR>
    <P><UL>
        <!--threads-->
	<LI>Previous message: <A HREF="000096.html">[99s-extend] cowboy and chromium
</A></li>
	<LI>Next message: <A HREF="000098.html">[99s-extend] Distributed model?
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#97">[ date ]</a>
              <a href="thread.html#97">[ thread ]</a>
              <a href="subject.html#97">[ subject ]</a>
              <a href="author.html#97">[ author ]</a>
         </LI>
       </UL>

<hr>
<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend
mailing list</a><br>
</body></html>