Performance testing in Go – Where to start from?

huangapple go评论71阅读模式
英文:

Performance testing in Go - Where to start from?

问题

我一直在学习Go语言,我只是一个新手。我刚刚完成了我的网站(仍然在本地主机上)。我想问一下是否有任何工具或框架、库可以测试服务器性能,同时跟踪响应时间。

我不知道从哪里开始,我的标准是测量每个请求的响应时间,创建虚拟自动会话以向服务器发送请求(登录、执行某些操作、注销),计算同时发送给服务器的请求有多少个得到了正确的响应等等。

我现在应该从哪里开始?我应该使用什么工具?

英文:

I've been learning Go. I'm just a newbie. I've just finished my web (still in localhost). I want to ask if there is any tools or framework, library that allows to test server performance, track response time parallel to running server.

I don't know where to begin from, criteria is from measuring response time for each request, creating virtual automatic session to send request to server (login, do something, logout), calculating how many requests sent simultaneously to server are properly responded, etc.

What should I start now? And what will I use?

答案1

得分: 2

使用内置工具应该是你所需要的大部分内容,你只需要学习有关工具的知识,比如编写基准测试函数。

这篇Go博客文章提供了一个概述,并提供了有关CPU/内存/争用工具的信息的链接:链接

Brad Fitzpatrick在他的演讲中详细介绍了如何使用性能分析工具,并提供了示例:链接

英文:

Using the built in tools should be most of what you need, you just need to learn about the tooling, like writing Benchmark test functions.

This go blog post has an overview and links to info about the cpu/memory/contention tooling.

Brad Fitzpatrick gave a good talk about using the profiling tools, with examples.

答案2

得分: 2

如果你想测试你在Go中编写的代码,你应该构建基准测试。为了达到这个目的,你可以阅读关于testing包的Golang文档这里。如果你有任何问题,请随时在这里写下来。

英文:

If you want to test the code you write in go you should build benchmark test. To achieve this result read the golang documentation about the package testing here. If you have any question feel free to write here

答案3

得分: 1

  1. 使用一个负载测试工具,这里是目前免费且开源的54个负载测试工具的列表。如果你想要一个简短的列表,可以查看开源负载测试工具:你应该使用哪一个?这篇文章。
  2. 最好使用另一台主机来运行负载测试,以避免相互干扰。
  3. 运行负载测试(大多数工具都具有录制和回放功能,对于基准测试来说应该足够了)。
  4. 如果你对响应时间不满意或者出现错误,需要调查和修复可能的原因,包括:
    • 网络应用程序方面的资源不足(CPU、内存、网络或磁盘IO)
    • 应用程序或Web服务器的配置不够优化
    • 应用程序代码存在问题
英文:
  1. Take a load testing tool, here is the list of 54 (as for now) free and open source load testing tools. If you want something short-listed check out Open Source Load Testing Tools: Which One Should You Use? article

  2. It's better to have another host to run your load test from to avoid mutual interference.

  3. Run load test (most tools have record and replay functionality, it should be enough for baseline testing)

  4. If you're unhappy with response times or get errors - investigate and fix the reason which could be:

    • lack of resources (CPU, RAM, Network or Disk IO) on your web application side
    • not optimal configuration of application or web server
    • something is wrong with your application code

huangapple
  • 本文由 发表于 2016年4月7日 15:54:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/36469982.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定