Commit Graph

115 Commits

Author SHA1 Message Date
Erik Dubbelboer f2ddaffc31 Remove CoarseTime
It is not clear why @valyala introduced this coarse time. Benchmarks on
different systems show that the speedup is no where enough to justify
the added code complexity and bugs it seems to have introduced.

Mac:
BenchmarkCoarseTimeNow-8   	2000000000	         2.49 ns/op
0 B/op	       0 allocs/op
BenchmarkTimeNow-8         	500000000	         3.14 ns/op
0 B/op	       0 allocs/op

Ubuntu:
BenchmarkCoarseTimeNow-4   	300000000	         6.74 ns/op
0 B/op	       0 allocs/op
BenchmarkTimeNow-4         	100000000	        15.9 ns/op
0 B/op	       0 allocs/op

This reverts commit https://github.com/erikdubbelboer/fasthttp/commit/6309f42188ecb28ccf8ac58442739cdb43d75d9e
and https://github.com/erikdubbelboer/fasthttp/commit/32c72cde80f0c591604f825586d6a4bbbb39d9c5.

See: https://github.com/valyala/fasthttp/issues/271,
https://github.com/valyala/fasthttp/pull/269 and
https://github.com/valyala/fasthttp/issues/261.
2018-08-17 17:15:41 +08:00
xPushkin f24d00fcc6 A lot of typo fixes 2017-10-08 13:30:35 +01:00
Aliaksandr Valialkin bcdf16d04f Removed superflouos slashes from documentation 2017-09-12 13:15:04 +03:00
Aliaksandr Valialkin 9ffce8c687 client: properly extract tls ServerName from address without port 2017-04-26 17:57:12 +03:00
Aliaksandr Valialkin 32c72cde80 Export CoarseTimeNow and clarify that RequestCtx.Time() and RequestCtx.ConnTime() return time truncated to a second 2017-02-10 15:45:14 +02:00
Aliaksandr Valialkin 6309f42188 optimization: substitute time.Now() calls with coarse-grained time in hot paths 2017-02-09 23:59:06 +02:00
Aliaksandr Valialkin 1c39678a4d client: retry non-idempotent requests if the server closes idle keep-alive connection before receiving the next request
This case usually appears when working with Apache or nginx servers.
See http://httpd.apache.org/docs/2.4/mod/core.html#keepalivetimeout
and http://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout
2016-11-28 11:50:36 +02:00
Aliaksandr Valialkin a965b01816 Added an example for LBClient 2016-10-21 14:53:44 +03:00
Aliaksandr Valialkin d18f43c48c Issue #191: Respect ServerName set in user-provided tls.Config 2016-10-20 15:26:25 +03:00
Aliaksandr Valialkin 4ca4d0ea09 Client, HostClient, PipelineClient: verify TLS server name 2016-10-12 19:49:23 +03:00
Aliaksandr Valialkin 07f692d02d Revert "Redirection support for Do(*Request, *Response)"
This breaks Get*() with redirects. DoFollowRedirects must be implemented
on top of Do() instead of hacking on internal doRequestFollowRedirects.

This reverts commit 6438022109.
2016-10-05 12:44:51 +03:00
Aliaksandr Valialkin 0509ba9f93 Revert "removing legacy doRequestFollowRedirects()"
This reverts commit 97e154e4cd.
2016-10-05 12:44:45 +03:00
Sick Yoon 97e154e4cd removing legacy doRequestFollowRedirects() 2016-10-05 12:37:18 +03:00
Sick Yoon 6438022109 Redirection support for Do(*Request, *Response) 2016-10-05 12:37:18 +03:00
Aliaksandr Valialkin aa4742b5ef HostClient: make sure only a single connsCleaner is running. Based on the PR #160 by @iizotop 2016-10-05 12:20:17 +03:00
Aliaksandr Valialkin a52a42acd6 Added HostClient.PendingRequests(), which may be used for balancing load among multiple HostClient instances 2016-09-21 23:03:30 +03:00
Aliaksandr Valialkin 4f66eb3fbb Do not busy wait on free connection in DoDeadline and DoTimeout, since this may result in a lot of goroutines stalled in the busy wait for free connections 2016-09-12 14:19:13 +03:00
Aliaksandr Valialkin 3e1cb31dcd Added SwapBody to Request and Response for zero-copy body pass between Request and Response objects 2016-09-12 13:42:59 +03:00
Nicolas Bazire 9f7999be97 fix DoDeadline side effect when no free conn (#145) 2016-08-17 20:24:33 +03:00
Aliaksandr Valialkin 881ac52b00 Added support for multiple concurrent connections to server in PipelineClient 2016-07-16 17:36:32 +03:00
Aliaksandr Valialkin f4ebbdd48b Removed incorrect statement from PipelineClient.Do docs 2016-07-15 14:41:07 +03:00
Aliaksandr Valialkin d1dd56c016 Issue #131: document redirects' following for client functions 2016-07-12 10:40:04 +03:00
Aliaksandr Valialkin 1fc1f4cbf5 Reduce memory usage under high load by pooling request/response bodies.
- Use request/response body pools.
- Defer request/response body allocation until it is really required.
- Return request/response bodies to the pool as soon as they become unused.

This minimizes the total amount of memory occupied by active request/response
bodies under high load.
2016-06-03 16:54:22 +03:00
Aliaksandr Valialkin f36b47782a removed memory allocations from tryDial. This should improve performance for non-keepalive connections 2016-05-16 17:17:18 +03:00
Aliaksandr Valialkin 281be30c26 Client optimization: reduce the number of SetReadDeadline/SetWriteDeadline calls for keep-alive connections, since they don't scale properly. See https://github.com/golang/go/issues/15133 for details. 2016-04-15 23:33:41 +03:00
Aliaksandr Valialkin e9544cbb6f client: get rid of slow math/rand for sleep jitter generation 2016-04-04 15:02:33 +03:00
Aliaksandr Valialkin 3f0e1bb92f PipelineClient: take into account queued requests waiting to be sent to the server in PendingRequests() 2016-04-03 11:19:52 +03:00
Aliaksandr Valialkin 9c292dcd3e PipelineClient: do not send timed out requests to the server 2016-04-03 11:11:27 +03:00
Aliaksandr Valialkin 316adc4782 PipelineClient.Do: try substituting the oldest request in the pending queue by the current one on queue overflow 2016-04-03 10:58:55 +03:00
Aliaksandr Valialkin 8ae2d3e53c PipelineClinet: added MaxBatchDelay option 2016-04-02 23:18:34 +03:00
Aliaksandr Valialkin ca21b21eba Return ErrPipelineOverflow from PipelineClient.Do if the pending requests' queue is overflown. This should prevent from caller's goroutines leak on stalled pipeline client 2016-04-01 18:21:35 +03:00
Aliaksandr Valialkin 22c9594090 Added PipelineClient for issuing pipelined requests to the server 2016-04-01 18:06:59 +03:00
Aliaksandr Valialkin 3298603593 client: added MaxIdleConnDuration for limiting the duration of idle keep-alive connections established by clients 2016-03-30 19:23:17 +03:00
Aliaksandr Valialkin 124195fdd8 create new default tls.Config instead of re-using existing config, since it may not be copied due to sync.Once member 2016-03-06 19:11:34 +02:00
Aliaksandr Valialkin 8280b7a162 Moved empty noCopy struct to the top of container structs. See @stemar94 's comment at https://github.com/golang/go/issues/12884 for details 2016-03-06 00:17:08 +02:00
Aliaksandr Valialkin 9f43aa1601 Do not expose noCopy.Lock 2016-03-04 21:20:52 +02:00
Aliaksandr Valialkin 9fa69c74af Embed noCopy struct into structs, which mustn't be copied
This should help `go vet` detecting invalid structs' copyings.
See https://github.com/golang/go/issues/8005#issuecomment-190753527 for details.
2016-03-04 16:57:24 +02:00
Aliaksandr Valialkin 3546c31c2b Issue #60: skip body copying in DoTimeout. This should improve DoTimeout performance when dealing with big request and/or response bodies 2016-03-01 01:13:50 +02:00
Aliaksandr Valialkin e252d37e21 Issue #57: Added DisableHeaderNamesNormalizing config option to Client and HostClient to be consistent with the corresponding option in Server 2016-02-29 13:11:32 +02:00
Aliaksandr Valialkin 7583b9b2ac client: use exponential backoff algorithm for sleeping between unsuccessful attempts to obtain free connection to the server. This should reduce CPU usage 2016-02-22 19:05:46 +02:00
Aliaksandr Valialkin 0ab0d45a50 Eliminated two memory allocations when client follows redirect 2016-02-19 17:27:47 +02:00
Aliaksandr Valialkin 9c9b5abffa Documentation update according to golint 2016-02-12 17:47:57 +02:00
Aliaksandr Valialkin df85922f86 Added (Get|Do)Deadline helper functions to Client and HostClient 2016-02-10 13:35:48 +02:00
Aliaksandr Valialkin a2e6d65e9d Issue #15: return more clear error if the server forgets sending 'Connection: close' response header before closing the connection 2016-02-05 13:45:46 +02:00
Aliaksandr Valialkin df213349e2 client: use TLS session cache by default 2016-02-04 20:24:00 +02:00
Aliaksandr Valialkin c450104658 Client: made more clear timeout handling 2016-01-29 13:38:56 +02:00
Aliaksandr Valialkin e3369ec00b Dial all the resolved TCP addresses in round-robin manner until the connection is established 2016-01-15 19:41:09 +02:00
Aliaksandr Valialkin 576ba8868b Return immediately on ErrDialTimeout when dialing HostClient hosts 2016-01-15 19:12:09 +02:00
Aliaksandr Valialkin a5f4f2e007 Dial all available addresses in HostClient.Addrs before giving up 2016-01-15 19:08:40 +02:00
Aliaksandr Valialkin c78eb83578 Client: re-send idempotent requests after more unsuccessful cases 2016-01-15 18:30:13 +02:00