title: Gremlin query via HTTP is extremely slow
body: <p>So, I'm running two very simple gremlin queries through both the Gremlin Console and via an HTTP request (issued from the same machine as the Gremlin Server resides on). The queries look like this:</p>
  
  <p>First query:</p>
  
  <pre><code>console: g.V(127104, 1069144, 590016, 200864).out().count()
  http: curl -XPOST -Hcontent-type:application/json -d '{"gremlin":"g.V(127104, 1069144, 590016, 200864).out().count()}' http://localhost:8182
  </code></pre>
  
  <p>Second query:</p>
  
  <pre><code>console: g.V(127104, 1069144, 590016, 200864).out().in().dedup().count()
  http: curl -XPOST -Hcontent-type:application/json -d '{"gremlin":"g.V(127104, 1069144, 590016, 200864).out().in().dedup().count()}' http://localhost:8182
  </code></pre>
  
  <p>It is by no means a huge graph - the first query returns 750 and the second query returns 9154. My problem is that I see huge performance differences between the queries run via HTTP compared to the console. For the first query both the console and the HTTP request returns immediately and looking at the gremlin server log, I'm please to see that the query takes only 1-2 milliseconds in both cases. All is good. </p>
  
  <p>Now for the second query, the picture changes. While the console continues to provide the answer immediately, it now takes between 4 and 5 seconds (!!) for the HTTP request to return the answer! The server log reports roughly the same execution time (some 50-60 ms) for both executions of the second query, so what is going on? I'm only doing a count(), so the slow HTTP response cannot be a serialization issues - it only needs to return a number, just as in the first query.</p>
  
  <p>Does anyone have any good ideas?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Running <code>profile()</code> gives some interesting results (screen shots attached below). It looks like everything runs way slower when called via HTTP, which to me makes no sense... </p>
  
  <p>From console:
  <a href="https://i.stack.imgur.com/njiU8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/njiU8.png" alt=""></a></p>
  
  <p>Via HTTP request:
  <a href="https://i.stack.imgur.com/ZcB5n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZcB5n.png" alt=""></a></p>