-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
any advice on improve performance on AWS #62
Comments
@valyala I added some parts of my code, sorry, it's very messy... |
@royxue , it would be great if you'll provide the following details:
The universal advice is to profile your program, detect and eliminate bottlenecks. |
@valyala Oh, ok, I will try to profile my project. However, is there any suggestion about achieve more CPU usage, I think this way would improve the performance. I tried ReusePort, but it seems not working very well.(May I did it wrong way, as Im just a beginner of Go) |
Below are comments regarding your code:
By the way, which program do you use for performance testing? Probably it sends requests over a small number of connections, so they load only a few CPU cores while other cores are idle. This may be fixed either by increasing the number of connections to the server or by moving expensive computations (I think this may be the code working with func requestHandler(ctx *fasthttp.RequestCtx) {
// move expensive computations to a separate goroutine and wait for the completion.
ch := make(chan struct{})
go func() {
defer close(ch)
requestHandlerSync(ctx)
}()
<-ch
}
func requestHandlerSync(ctx *fasthttp.RequestCtx) {
l, _ := time.LoadLocation("EST")
t := time.Now().In(l).String()[:19]
keyX := new(big.Int)
keyX.SetString("64266330917908644872330635228106713310880186591609208114244758680898150367880703152525200743234420230", 10)
keyY := new(big.Int)
keyY.SetString(string(ctx.QueryArgs().Peek("key")[:]), 10)
keyZ := gcd(keyX, keyY)
var k = 1 + keyZ % 25
message := ctx.QueryArgs().Peek("message")
n := int(math.Sqrt(float64(len(message))))
final := string(matrix(n, message, int(k)))
fmt.Fprintln(ctx, "Awesomething,3879-5761-4082")
fmt.Fprintln(ctx, t)
fmt.Fprintln(ctx, final)
} |
@valyala |
They differ in the level of details you can control on the server:
|
I just started to use fasthttp, I checked the CPU usage is only around 20%, I want to improve performance.
is there any advice on how to improve performance on AWS?
The text was updated successfully, but these errors were encountered: