wrk

Go pprof性能调优

扶醉桌前 提交于 2020-05-03 19:43:46
Go性能调优 在计算机性能调试领域里,profiling 是指对应用程序的画像,画像就是应用程序使用 CPU 和内存的情况。 Go语言是一个对性能特别看重的语言,因此语言中自带了 profiling 的库,这篇文章就要讲解怎么在 golang 中做 profiling。 Go性能优化 Go语言项目中的性能优化主要有以下几个方面: CPU profile:报告程序的 CPU 使用情况,按照一定频率去采集应用程序在 CPU 和寄存器上面的数据 Memory Profile(Heap Profile):报告程序的内存使用情况 Block Profiling:报告 goroutines 不在运行状态的情况,可以用来分析和查找死锁等性能瓶颈 Goroutine Profiling:报告 goroutines 的使用情况,有哪些 goroutine,它们的调用关系是怎样的 采集性能数据 Go语言内置了获取程序的运行数据的工具,包括以下两个标准库: runtime/pprof :采集工具型应用运行数据进行分析 net/http/pprof :采集服务型应用运行时数据进行分析 pprof开启后,每隔一段时间(10ms)就会收集下当前的堆栈信息,获取格格函数占用的CPU以及内存资源;最后通过对这些采样数据进行分析,形成一个性能分析报告。 注意,我们只应该在性能测试的时候才在代码中引入pprof。

WRK-HTTP压力测试工的下载安装与使用方法

天涯浪子 提交于 2020-03-05 15:05:11
wrk 是一款采用异步并发模型的HTTP基准测试工具:采用异步并发模型,能够发送更大且可控的压力;内置 LuaJIT,能够通过 lua 脚本模拟常见的业务行为,模拟更加真实的场景;相比常见的HTTP基准测试工具,占用更少CPU、更少内存; 支持 HTTP、 HTTPS,能够动态修改头、修改Body方法等;支持混合场景 编译安装 1.sudo yum groupinstall ‘Development Tools’ 2.sudo yum install openssl-devel 3.sudo yum install git #下载安装git,并下载wrk 4.git clone https://github.com/wg/wrk.git 5.cd wrk 6.make 基本测试方法: wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html This runs a benchmark for 30 seconds, using 12 threads, and keeping 400 HTTP connections open. Output: Running 30s test @ http://127.0.0.1:8080/index.html 12 threads and 400 connections Thread Stats

Is there a way to pass parameters to GET request using wrk?

拟墨画扇 提交于 2019-12-05 04:56:26
问题 I need to benchmark a REST API that takes parameters as input. I wondering if there is a way to do it using wrk . Right now I don't see such an option: user@Ubuntu-K56CA:~/wrk$ ./wrk Usage: wrk <options> <url> Options: -c, --connections <N> Connections to keep open -d, --duration <T> Duration of test -t, --threads <N> Number of threads to use -s, --script <S> Load Lua script file -H, --header <H> Add header to request --latency Print latency statistics --timeout <T> Socket/request timeout -v,

Load Testing and Benchmarking With siege vs wrk

吃可爱长大的小学妹 提交于 2019-12-04 07:40:01
问题 I have been looking around for tools that can help me to do load testing and benchmarking. I found couples like: https://github.com/wg/wrk , http://www.joedog.org/siege-home/ , https://github.com/rakyll/boom . I'm wondering if anyone has any experience with these tools and have any feedback pros vs cons of these tools. My load stress will include different test cases using DELETE, PUT, GET, POST... headers Thanks 回答1: I've used wrk and siege, siege is a really easy to use tool, but I'm not

Spring Cloud Gateway 、Zuul、EdgeService性能对比

倖福魔咒の 提交于 2019-12-04 06:43:34
关键字:网关,Zuul,Gateway,Spring Cloud, ServiceComb,Edge Service性能测试,微服务 作者 | 李昂 导读 本文对几种流行的 API 网关以关键指标 RPS 为依据,利用 wrk 做出性能测评并且给出结论。本文所有使用的软件、命令、以及代码均在文中注明,以便读者搭建本地环境进行测试。注意性能测试的数据在不同的运行环境中差别较大,但总体上来说各项数据会成比例变化,本文的测试过程和结论可以较准确地反应出各 API 网关之间的性能差异。 背景知识介绍 API 网关 近些年来,在云时代的背景下,为了适应互联网和大数据的高速发展,随着微服务架构的持续火热,对 API 网关的诉求越来越强烈,API 网关的产品也层出不穷。除了传统的 Zuul 和 SpringCloud Gateway, 还诞生了很多优秀的网关,本文选取了Edge Service 作为比较对象与传统的网关进行了 API 网关的性能测评。 究竟是久经沙场的老牌网关更经得起考验,还是新兴的网关性能更优?本文将给出详细的测评过程和结果。 Netflix Zuul Zuul 在这三个网关中是最早诞生的,其 github repo 早在 2013 年之前就已经存在,同年开始进入大众视野,崭露头角。虽然 Zuul 诞生较早,也占据着不小的市场份额,但由于 Zuul本身是基于阻塞io开发的

Load Testing and Benchmarking With siege vs wrk

∥☆過路亽.° 提交于 2019-12-02 15:18:12
I have been looking around for tools that can help me to do load testing and benchmarking. I found couples like: https://github.com/wg/wrk , http://www.joedog.org/siege-home/ , https://github.com/rakyll/boom . I'm wondering if anyone has any experience with these tools and have any feedback pros vs cons of these tools. My load stress will include different test cases using DELETE, PUT, GET, POST... headers Thanks I've used wrk and siege, siege is a really easy to use tool, but I'm not sure if you can test DELETE or PUT with siege. Wrk can use provided lua script to generate requests, so DELETE

bucket4j-spring-boot-starter小试牛刀

久未见 提交于 2019-11-30 06:41:42
序 本文主要研究一下如何使用bucket4j-spring-boot-starter进行限流 maven <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> </dependency> <dependency> <groupId>javax.cache</groupId> <artifactId>cache-api<

几款常用压测工具推荐

╄→гoц情女王★ 提交于 2019-11-29 10:06:08
ab ab是apache自带的压力测试工具,使用起来非常方便. 安装 如果安装了apache, 那么ab已经安装好了,如果不想安装apache的话,可以通过以下方式安装ab # ubuntu sudo apt-get install apache2-utils # centos yum -y install httpd-tools 压测 在压测前,需要关注几个选项,通过 ab -help 查看 Options are: -n requests 要执行的请求次数 -c concurrency 并发数量 -s timeout 响应时间 执行 ab -n 1000 -c 100 -s 1 http://127.0.0.1:1080/event?config_name=mysql_config # 总共100个并发执行1000此请求,超时时间为1s 结果分析 在执行上述测试命令后,得到如下结果,主要关注以下几个指标: Failed requests:失败的请求 Requests per second:也就是常说的QPS, 每秒查询率, 这是一个平均值 Time per request:完成一个请求所花费的时间 Transfer rate: 网络传输速度。 对于大文件的请求测试,这个值很容易成为系统瓶颈所在 要确定该值是不是瓶颈,需要了解客户端和被测服务器之间的网络情况

线程同步之详解自旋锁

假如想象 提交于 2019-11-26 12:20:56
一 什么是自旋锁 自旋锁(Spinlock)是一种广泛运用的底层 同步 机制。自旋锁是一个 互斥 设备,它只有两个值:“锁定”和“解锁”。它通常实现为某个整数值中的某个位。希望获得某个特定锁得代码测试相关的位。如果锁可用,则“锁定”被设置,而代码继续进入 临界区 ;相反,如果锁被其他人获得,则代码进入 忙循环 (而不是休眠,这也是自旋锁和一般锁的区别)并重复检查这个锁,直到该锁可用为止,这就是自旋的过程。“测试并设置位”的操作必须是原子的,这样,即使多个线程在给定时间自旋,也只有一个线程可获得该锁。 自旋锁对于SMP和单处理器可抢占内核都适用。可以想象,当一个处理器处于自旋状态时,它做不了任何有用的工作,因此自旋锁对于单处理器不可抢占内核没有意义,实际上,非抢占式的单处理器系统上自旋锁被实现为空操作,不做任何事情。 曾经有个经典的例子来比喻自旋锁:A,B两个人合租一套房子,共用一个厕所,那么这个厕所就是共享资源,且在任一时刻最多只能有一个人在使用。当厕所闲置时,谁来了都可以使用,当A使用时,就会关上厕所门,而B也要使用,但是急啊,就得在门外焦急地等待,急得团团转,是为“自旋”,这也是要求锁的持有时间尽量短的原因! 自旋锁有以下特点: ___________________ 用于临界区互斥 在任何时刻最多只能有一个执行单元获得锁 要求持有锁的处理器所占用的时间尽可能短