Commit Graph

959 Commits

Author SHA1 Message Date
Aliaksandr Valialkin 2db9429ff7 added a fast path to decodeArgAppend when the arg doesnt contain encoded chars 2017-06-20 13:40:15 +03:00
Aliaksandr Valialkin c0de95e84b Added AppendUnquotedArg - the complementary function to AppendQuotedArg 2017-06-19 18:35:07 +03:00
Aliaksandr Valialkin b154429ca9 Compress responses only if their content-type starts with text/ or application/ 2017-05-17 17:10:29 +03:00
Aliaksandr Valialkin 103adc311e Do not compress responses with sizes smaller than 200 bytes
Compressing small bodies has little sense, since the compressed result size
may exceed the original body size.

This should save CPU time when the server responds with small responses.
2017-05-17 16:17:53 +03:00
Aliaksandr Valialkin 30e92af08f Limit heap memory usage when compressing high number of concurrent responses
Previously each concurrent compression could allocate huge compression state
with the size up to 1Mb each. So 10K concurrent connections could result in
10Gb of compression state in the heap.

This CL limits the number of compression states among concurrent requests
when {Append,Write}{Gzip,Deflate}* functions are called to O(GOMAXPROCS).
These functions are used by CompressHandler* for non-streaming responses,
i.e. it should cover the majority of use cases.

Memory usage for 10K concurrent connections that compress responses drops
from 10Gb to 200Mb after this CL.
2017-05-17 14:45:31 +03:00
Aliaksandr Valialkin 9ffce8c687 client: properly extract tls ServerName from address without port 2017-04-26 17:57:12 +03:00
Aliaksandr Valialkin 8b2cc86299 fasthttputil: added TLS benchmarks for ECDSA certificates
Handshakes with ECDSA certificates are optimized much better
comparing to RSA certificates - see https://github.com/golang/go/issues/20058 .
2017-04-24 14:16:32 +03:00
Aliaksandr Valialkin 8d2055d00a fasthttputil: added TLS benchmarks for handshakes with elliptic curves 2017-04-20 19:05:57 +03:00
Aliaksandr Valialkin 2c5a87147a fasthttputil: added BenchmarkTLSHandshakeWithoutClientSessionCache 2017-04-20 12:31:46 +03:00
Aliaksandr Valialkin fc109d6887 Added a benchmark for RequestCtx.Redirect 2017-02-22 18:45:09 +02:00
Perelandric 3580c93d02 Make SetMethod slice to zero before appending (#234)
SetMethod appended directly to the `h.method` slice without setting its
length to zero, so multiple calls would create an unexpected value.
2017-02-22 09:48:29 +02:00
Aliaksandr Valialkin de05aa4747 travis: test with go1.8 2017-02-20 18:59:34 +02:00
Aliaksandr Valialkin f06438ae94 doc: mention that RequestCtx.ConnRequestNum() returns connection request numbers starting from 1 2017-02-20 16:00:55 +02: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 e113a6dfce stackless: use dedicated worker pool per each stackless func.
This reduces tail latencies in our prod when multiple stackless funcs
are used concurrently.
2017-02-06 14:23:39 +02:00
Aliaksandr Valialkin 07559fc63b stackless: send "func done" notification over a buffered channel, so the funcWorker could process multiple work items without switching to other goroutines 2017-02-06 01:10:21 +02:00
Aliaksandr Valialkin 5abb44878e stackless: added NewFunc() for wrapping stack-hungry CPU-bound functions 2017-02-05 23:35:23 +02:00
Aliaksandr Valialkin b69eba7101 Added Args.GetBool helper 2017-01-30 19:47:15 +02:00
Aliaksandr Valialkin 2ada93a6df Document that the cookie passed to ResponseHeader.SetCookie may be re-used after the function returns 2017-01-18 19:20:47 +02:00
Aliaksandr Valialkin b0de56d13b Properly set "https" scheme in RequestCtx.URI() for TLS connections 2017-01-15 00:26:21 +02:00
Aliaksandr Valialkin 21021ceb31 Added a test for redirecting from https to schemeless url 2017-01-14 23:40:56 +02:00
Aliaksandr Valialkin 0a7f0a797c Updated tests and documentation for URI.Parse and URI.Update* regarding uris without scheme 2017-01-09 10:50:56 +02:00
Aliaksandr Valialkin 82894ea1e8 Added RequestCtx.LocalIP() 2016-12-14 13:51:36 +02:00
Aliaksandr Valialkin 1dc5bc133b Issue #207: mention lu in more places. Remove echo, since it dropped fasthttp support starting from v3 2016-12-05 18:36:47 +02:00
Aliaksandr Valialkin f644fdc7de Issue #207: Mention lu framework in README.md 2016-12-05 18:33:11 +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 1913bdea45 Set 'Connection: close' response header when server couldn't parse or accept incoming request 2016-11-17 13:50:15 +02:00
Aliaksandr Valialkin ef299a95e2 Fixed TestServerErrSmallBuffer for go 1.6 2016-11-14 23:16:56 +02:00
Aliaksandr Valialkin e0618f8ef5 an attempt to localize travis failure on TestServerErrSmallBuffer 2016-11-14 22:56:00 +02:00
Aliaksandr Valialkin 78e415082d an attempt to fix travis build 2016-11-14 22:40:43 +02:00
Aliaksandr Valialkin 89fe89ae74 stackless: optimization: do not issue zero-length writes to underlying writer 2016-11-11 15:16:52 +02:00
Aliaksandr Valialkin 3246b4efb5 Issue #173: improve error messages on headers parsing 2016-11-10 20:00:54 +02:00
Aliaksandr Valialkin 02fe9b8533 Issue #173: return valid response instead of silently closing connection on request parsing errors 2016-11-10 18:09:23 +02:00
Aliaksandr Valialkin b7e3627df2 LBClient: prevent servers' hammering by randomizing the initial client to use 2016-11-09 19:11:48 +02:00
Aliaksandr Valialkin 6cd438ba89 LBClient: panic on empty Clients 2016-11-07 17:21:28 +02:00
Aliaksandr Valialkin f49c6b3f96 Reduce stack space usage when using response compression 2016-11-03 19:38:42 +02:00
Aliaksandr Valialkin 4ee6517626 Issue #193: properly handle nil body when calling WriteGzip* and WriteDeflate* on Response struct 2016-10-31 13:41:50 +02:00
Aliaksandr Valialkin 44f08d5588 Issue #196: avoid returning (nil, nil) from fasthttp.Dial* 2016-10-29 23:02:11 +03:00
Aliaksandr Valialkin cd7c1dafbc Properly handle TimeoutHandler in custom server implementations, which use RequestCtx.Init* functions 2016-10-21 15:39:05 +03:00
Aliaksandr Valialkin a965b01816 Added an example for LBClient 2016-10-21 14:53:44 +03:00
Aliaksandr Valialkin 935c556b36 Added RequestCtx.Hijacked method for determining whether the underlying connection is hijacked 2016-10-21 14:33:22 +03:00
Aliaksandr Valialkin 204fed9187 Revert "Use standard compress packages until https://github.com/klauspost/compress/issues/64 is fixed"
The original issue has been fixed, so reverting.

This reverts commit 2f4876aaf2.
2016-10-20 18:02:21 +03:00
Aliaksandr Valialkin 2f4876aaf2 Use standard compress packages until https://github.com/klauspost/compress/issues/64 is fixed 2016-10-20 15:30:15 +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 b5d497902b Added LBClient for balancing load among multiple clients
This will be used by httptp from https://github.com/valyala/httpteleport .
2016-10-20 13:49:00 +03:00
Aliaksandr Valialkin 8ab3351f0a Unshadow err in client test 2016-10-13 17:42:25 +03:00
Aliaksandr Valialkin 93c15ed83c Remove unused variables 2016-10-13 17:40:57 +03:00
Aliaksandr Valialkin e0c9f3d5ff typo fixes in comments 2016-10-13 17:39:06 +03:00
Aliaksandr Valialkin 432960e479 Issue #188: Add tests for empty header values' parsing 2016-10-13 16:17:09 +03:00