Erik Dubbelboer
8dfc881b9e
Added Server.nextProtos
...
This implementation allows user to handle crypto/tls.Config.NextProtos to use their own handlers for the negotiated TLS protos like HTTP/2.
Workerpool where changed to adapt WorkerFunc to another conns server with ServeConn type and contains the Server structure which creates to check configured protos.
2018-10-05 16:35:59 +08:00
Xu Qiaolun
c88d0992b4
vendor ConnState type in fasthttp package
2018-08-30 15:20:32 +00:00
徐乔伦
69613e6feb
add support for http.ConnState
...
issue #205
2018-08-30 15:20:32 +00:00
Erik Dubbelboer
fbf4b2d9cd
Do not log ErrSmallBuffer for request headers
...
fasthttp returns a 431 error when the request headers are too large.
Most other HTTP servers do not log an error when the request header
exceeds the limit. When serving HTTP requests directly to browsers,
it is normal to occasionally hit the limit due to broken browsers
or broken sites linking to your resource. These issues are generally
outside of your control in the same way the already ignored errors are.
2018-08-27 21:30:11 +00:00
Kirill Danshin
ef10ed05a3
deprecate CoarseTime and replace it with a shortcut implementation
...
Signed-off-by: Kirill Danshin <k@guava.by >
2018-08-17 18:12:21 +03:00
Kirill Danshin
4c7269ec2a
Revert "Remove CoarseTime"
...
This reverts commit f2ddaffc31 .
2018-08-17 15:32:15 +03:00
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
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
a2cc660e59
optimization: removed slow defer from worker pool handler and hijack handler
2016-07-18 17:23:38 +03:00
Aliaksandr Valialkin
886e541160
Removed 'recover-from-panic' band-aids.
...
All the panics must be handled by the user code.
2016-07-12 12:30:38 +03:00
Aliaksandr Valialkin
a0377f758e
workerpool: test cleaner
2016-03-31 14:56:39 +03:00
Aliaksandr Valialkin
9f20a62336
added workerpool tests
2016-03-31 14:41:27 +03:00
Aliaksandr Valialkin
4fa2d5db39
workerpool: bugfix: do not return workerChan to ready pool on panic
2016-03-31 12:37:46 +03:00
Aliaksandr Valialkin
e64702d6f0
workerpool: removed a hack for recycling worker stacks, since Go runtime must be able to shrink big stacks when they aren't needed
2016-03-31 10:31:53 +03:00
Aliaksandr Valialkin
72352d7661
workerpool: limit the number of connections each worker may serve. This should reduce the total amount of memory occupied by worker stacks in the long term
2016-03-30 19:35:46 +03:00
Aliaksandr Valialkin
1f148c6c09
workerpool: properly clean scratch buffer for workerChans
2016-03-30 19:04:20 +03:00
Aliaksandr Valialkin
1d6b6a6608
workerpool: properly count workers
2016-03-30 18:45:57 +03:00
Aliaksandr Valialkin
92c779039c
workerpool: clean workerChan slices in order to reduce the amount of work for GC
2016-03-30 18:11:40 +03:00
Aliaksandr Valialkin
8094a6e20f
workerpool: reduced the time to hold the lock when cleaning unused worker goroutines
2016-03-30 16:40:16 +03:00
Aliaksandr Valialkin
dbea792cf7
Scalability improvement: use distinct workerChan pool per each workerPool
2016-03-29 11:45:09 +03:00
Aliaksandr Valialkin
023e3807b8
workerPool optimization: determine the current time outside lock
2016-03-29 11:05:14 +03:00
Aliaksandr Valialkin
e4c0cbe843
code prettifying
2016-03-02 16:10:38 +02:00
Aliaksandr Valialkin
ed7ca4c631
Added LogAllErrors config parameter to Server, which allows logging the most frequent errors such as 'connection reset by peer', 'broken pipe' and 'i/o timeout'. By default such errors are suppressed
2016-02-19 12:01:27 +02:00
Aliaksandr Valialkin
a9a9b08a84
Do not pollute server error log with 'i/o timeout' errors
2016-01-28 12:03:07 +02:00
Aliaksandr Valialkin
180e104034
Fixed misleading comments in workerpool
2015-12-10 12:05:36 +02:00
Aliaksandr Valialkin
3c903772f2
Avoid memory allocation when cleaning stale workers and connections
2015-12-02 08:24:55 +02:00
Aliaksandr Valialkin
235d4932da
Check for stale workers and connections every 10 seconds instead of every second. This should reduce cleaners' overhead
2015-12-01 13:42:53 +02:00
Aliaksandr Valialkin
a3965934a1
Simplify GC life by zeroing references to closed worker chans and client conns
2015-12-01 13:32:05 +02:00
Aliaksandr Valialkin
f214dc327f
Scalability improvement: do not move read workers' queue when cleaning old workers. This should reduce latencies when server serves multi-million concurrent connections
2015-11-30 11:26:39 +02:00
Aliaksandr Valialkin
bc85e2b572
workerpool: immediately switch to connection processing if GOMAXPROCS=1. This improves single-threaded server performance by 1-2%
2015-11-26 12:38:18 +02:00
Aliaksandr Valialkin
45e1d5a313
fixed a typo
2015-11-24 13:59:51 +02:00
Aliaksandr Valialkin
cd4ace5409
Close connection and release worker channel on panic in WorkerFunc
2015-11-24 13:40:39 +02:00
Aliaksandr Valialkin
146145240d
Added RequestCtx.Hijack() for connections' hijacking
2015-11-23 19:41:43 +02:00
Aliaksandr Valialkin
bb38369834
Suppress too chatty 'reset by peer' errors when serving clients, which unexpectedly close connections
2015-11-23 13:01:36 +02:00
Aliaksandr Valialkin
76f453b7fc
Suppress too chatty 'broken pipe' errors when serving clients, which unexpectedly close connections
2015-11-23 12:57:37 +02:00
Aliaksandr Valialkin
6e4b32182e
Fixed panic when WorkerFunc returns error and Conn is closed
2015-11-12 14:01:04 +02:00
Aliaksandr Valialkin
f4223fbb70
Added missing unlock when stopping worker pool
2015-11-11 18:08:15 +02:00
Aliaksandr Valialkin
a4e8e226ff
Removed dubious loop for obtaining free worker - just increase the number of workers if 'no free workers' error occur
2015-11-11 16:39:59 +02:00
Aliaksandr Valialkin
69758b81d6
Accept net.Conn instead of io.ReadWriteCloser in Serve*() methods, since in reality we use net.Conn methods such as RemoteAddr, SetReadDeadline and SetWriteDeadline
2015-11-11 16:17:12 +02:00
Aliaksandr Valialkin
ae6a7cc17c
Extracted workerPool from server.go into workerpool.go
2015-11-11 15:27:27 +02:00