NSURLRequest setTimeoutInterval does not work as expected - iphone

I have kept NSURLRequest timeout interval 30sec. And I have also configured the auto retry 3 times for request. So if any problem comes in request then total time should be 120 seconds (i.e. 2 mins).
But When i have kept Debug point on my server and if i request to server then my time out period is getting 3 minutes.
Can I configure this timeout??? Or it should work??
Is this default timeout interval Once request is made to Server??

Please note that 30 seconds times 3 is 90 seconds, or one and a half minutes, not 2 minutes.
As for the timeout problem, try to init your NSURLRequest with initWithURL:cachePolicy:timeoutInterval:. Make sure to check the status of your NSURLConnection delegate methods, especially in connection:didFailWithError:.
Also, maybe you should explain how you measure the time out period on the server.

Related

Session time out set by Curator Framework

I have just started using curator framework and found something that was very interesting and wanted to check if I my assumption is correct. Session time out in Zookeeper is twice the tikr time. So in my local zookeeper config file my tikr time is 8 seconds so the session time out becomes 16 seconds. Now when I create curator framework and set session time out to a value less than 16 seconds the negotiated session time out is set to 16 seconds but if I set the session timeout in the curator framework to say 25 seconds then the negotiated session time out is 25 seconds. Is it right to assume that the greater of the 2 values is set as session time out value?
The client sends a requested timeout, the ZK server responds with the timeout that it can give the client.
The current implementation requires that the timeout be a minimum of 2 times the tickTime (as set in the server configuration) and a maximum of 20 times the tickTime.
So a value less than 16 (8 * 2) will be increased to 16, and 25 is okay.
See https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#ch_zkSessions for more details

How does jmeter starts sending requests to server

If Thread: 100, Rampup: 1 and Loop count: 1 is the configuration, how will jmeter start sending requests to the server?
Request will be sent 1 req/sec or all requests will be sent all at once to server?
JMeter will send requests as fast as it can, to wit:
It will start all threads (virtual users) you define in Thread Group within the ramp-up period (in your case - 100 threads in 1 second)
Each thread (virtual user) will start executing Samplers which are present in the Thread Group upside down (or according to the Logic Controllers)
When there are no more samplers to execute or loops to iterate the thread will be shut down
When there are no more active threads left - JMeter test will end.
With regards to requests per second - it mostly depends on your application response time, i.e.
if you have 100 virtual users and response time is 1 second - you will get 100 requests/second
if you have 100 virtual users and response time is 2 seconds - you will get 50 requests/second
if you have 100 virtual users and response time is 500 milliseconds - you will get 200 requests/second
etc.
I would recommend increasing (and decreasing) the load gradually, this way you will be able to correlate increasing load with increasing throughput/response time/number of errors, etc. while releasing all threads at once will not tell you the full story (unless you're doing a form of spike testing, in this case consider using Synchronizing Timer)
JMeter's ramp-up period set as 1 means to start all 100 threads in 1 second.
This isn't recommended settings as describe below
The ramp-up period tells JMeter how long to take to "ramp-up" to the full number of threads chosen. If 10 threads are used, and the ramp-up period is 100 seconds, then JMeter will take 100 seconds to get all 10 threads up and running. Each thread will start 10 (100/10) seconds after the previous thread was begun. If there are 30 threads and a ramp-up period of 120 seconds, then each successive thread will be delayed by 4 seconds.
Ramp-up needs to be long enough to avoid too large a work-load at the start of a test, and short enough that the last threads start running before the first ones finish (unless one wants that to happen).
Start with Ramp-up = number of threads and adjust up or down as needed.
See also Can i set ramp up period 0 in JMeter?
bear in mind that with low rampup and many threads, you may be limited by local resources, so your results may be a measurement of client capability rather than server.

How to test the page loading time with Gatling

For example- I need to check that for 1000 users it responds in 3 seconds.
Is the number of users and response times configurable?
This answer targets Gatling 2.
You can set the target number of users by configuring the "injection profile" of your simulation:
setUp(scn.inject(atOnceUsers(1000)) // To start all users at the same time
setUp(scn.inject(rampUsers(1000) over (30 seconds) // To start gradually, over 30 seconds
For more information, please refer to the injection DSL documentation
If you want to check that all your users responds in less than 3 seconds, one way to ensure this is Gatling's assertions:
setUp(...).assertions(global.responseTime.max.lessThan(3000))
If this assertion fails, meaning at least one user responded in more than 3 seconds, Gatling will clearly indicate the failure after your simulation is completed.

HttpUrlConnection taking exactly 2 minutes for timeout

Whenever the URL is trying to load, it takes larger than the time set in the connection timeout, but setting the connection timeout to 20 seconds does not work it happens only after 2 minutes, and also whatever the time that is set in the connection time out, its taking exactly 2 minutes for the server to connection time out.
URL urlConnect = new URL(url.toString());
HttpURLConnection urlc = (HttpURLConnection) urlConnect.openConnection();
urlc.setDoInput(true);
urlc.setConnectTimeout(1000 * 20); // Timeout is in MILLI seconds
urlc.connect();
Or whether the 2 minutes is the default values for timeout? how to set the timeout to exactly 20 seconds. It doesnot have any redirect urls or anythings its a plain url. Why is it taking exactly 2 minutes for the connection to timeout?

Problem with nsurlconnection timeout

I've got a wierd problem with NSURLConnection. I've set the connection time out of 20 seconds like this.
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
NSURLConnection *con= [[NSURLConnection alloc] initWithRequest:request delegate:self];
I'm implementing the delegate methods for the NSURLConnection as well.
Now when I ran the app, the connection did not time out after 20 seconds but after 2-3 minutes it gave error for 'No internet connection'. Isn't it supposed to give a timeout error after 20 seconds?
The discussion for timeoutInterval says that it starts (is set to 0) when a process of load activity occurs:
The timeout interval specifies the
limit on the idle
interval alloted to a request in the process of loading. The "idle
interval" is defined as the period of time that has passed since the
last instance of load activity occurred for a request that is in the
process of loading. Hence, when an instance of load activity occurs
(e.g. bytes are received from the network for a request), the idle
interval for a request is reset to 0. If the idle interval ever
becomes greater than or equal to the timeout interval, the request
is considered to have timed out. This timeout interval is measured
in seconds.
No internet connection is an error. So probably the timeout will actually occur in 20 seconds (set time) if it gets a connection but takes more time to load...