Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8422239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:23:28+00:00 2026-06-10T03:23:28+00:00

Why is the first http request on data so slow? I’m using something on

  • 0

Why is the first http request on data so slow?

I’m using something on the following lines: Doing 3 HTTP requests in a row (one after each other) and then wait a given time and loop again with doing the 3 HTTP requests.

I’m using keep-alive which is basically also working but on the first HTTP request there is a 2 second penalty each time I start with the 3 HTTP request. Only the first HTTP request has this 2 second penalty. If I lower the time waiting between the consecutive HTTP requests to something like 200ms all of the request are fast without having the first one seeing this 2 second penalty.

Obviously this sounds like the first request might not use the keep alive connection but that is actually not the case. I run tcpdump on the server and I can clearly see that all requests are using the same TCP connection without closing and building up again a new connection. The keep alive setting on the server is set to 60s while the time waiting on the app is for example 5 seconds. Also when I switch to WIFI this behavior I cannot see. With the same time waiting all requests are fast.

The http connect code is using HttpURLConnection and looks like the following:

m_res.error = null;
HttpURLConnection connection;
try {
    connection = (HttpURLConnection)(new URL(m_url + "/" + m_call.command).openConnection());
    connection.setDoOutput(true); // triggers POST.
    connection.setDoInput(true);
    connection.setRequestProperty("Accept-Charset", m_charset);
    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + m_charset);
    connection.setRequestProperty("Connection", "Keep-Alive");
    connection.setRequestProperty("Accept-Encoding", "gzip");
    //connection.setChunkedStreamingMode(0);
    OutputStream output = null;

    try {
        output = connection.getOutputStream();
        output.write(m_call.query_string.getBytes(m_charset));
        InputStream response = null;
        try {
            response = connection.getInputStream();
            if ("gzip".equals(connection.getContentEncoding())) {
                response = new GZIPInputStream(response);
            }
        }
        catch (IOException e) {
            response = connection.getErrorStream();
        }
        if (response == null) {
            m_res.error = "Connection Error";
        }
        else {
            m_res.body = getAsString(response);
            m_res.status = connection.getResponseCode();
        }
    } 
    catch (IOException e) {
        e.printStackTrace();
        m_res.error = "Connection Error";
    }
    finally {
        if (output != null) 
                try { 
                    output.close(); 
                } catch (IOException logOrIgnore) {}
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:23:29+00:00Added an answer on June 10, 2026 at 3:23 am

    I think one possible answer to this is that the devices data connection on a layer below IP is changing its status e.g. maybe there is some sort of standby status which kicks in when there is no incoming or outgoing data for a given time e.g. like in my example 5 seconds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which one of the following node.js HTTP proxy implementations is more performant? The first
var request = new WebClient(); request.DownloadFile(http://2nditeration.ca/Images/facebook.png, C:\tmp\filename.png); The first parameter is saying there are
Starting with no cache on server or client FIRST REQUEST GET /post/1 HTTP/1.1 HTTP/1.1
After launching our first public alpha release of http://wwww.trademango.com which is built with Play
http://dspace.dial.pipex.com/town/green/gfd34/art/bloopers.html The first one seems simple; return strcpy(malloc(strlen(s)), s); malloc could return null ,
Using Fiddler , we see 3 HTTP requests (and matching responses) for each call
I have HTTP header request and reply data in tab delimited form with each
I'm making simple http post request using libcurl to index.php file on my web
I need to make an http request for JSON data on a sharepoint site.
consider the following http request: GET /defects?group-by=priority I would like the returned collection(feed) of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.