Comments (4)
maybe I should read source code from here: https://github.com/valyala/fasthttp . here is the best practice from fasthttp
:
Fasthttp best practices
- Do not allocate objects and
[]byte
buffers - just reuse them as much
as possible. Fasthttp API design encourages this. - sync.Pool is your best friend.
- Profile your program
in production.
go tool pprof --alloc_objects your-program mem.pprof
usually gives better
insights for optimization opportunities thango tool pprof your-program cpu.pprof
. - Write tests and benchmarks for hot paths.
- Avoid conversion between
[]byte
andstring
, since this may result in memory
allocation+copy. Fasthttp API provides functions for both[]byte
andstring
-
use these functions instead of converting manually between[]byte
andstring
.
There are some exceptions - see this wiki page
for more details. - Verify your tests and production code under
race detector on a regular basis. - Prefer quicktemplate instead of
html/template in your webserver.
from guard.
I'm gonna handle this. but February is Chinese spring festival, I'll do it in March.
from guard.
before March, I'm gonna doing these things for prepare:
- read HTTP RFC
- read implementation of fasthttp
from guard.
done by #16
from guard.
Related Issues (16)
- add benchmark for breaker.ServeHTTP HOT 1
- rewrite radix tree, drop dependency of httprouter HOT 1
- rewrite Bucket, use radix tree HOT 1
- more load balance algorithms HOT 1
- add option to config balance algorithm HOT 3
- 试试调整 GOGC HOT 4
- use a coarse implementation HOT 1
- radix tree, use `[]byte` to save path & indices HOT 1
- dynamic config load & save HOT 2
- benchmark for guard vs nginx HOT 1
- web ui HOT 2
- graceful restart HOT 1
- add fallback option HOT 1
- Differences with Kong HOT 1
- TLS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guard.