发表于: 2020-07-02 22:22:03
1 1943
今天完成的事情:Jmeter压测
在Windows系统上将IP地址:端口号 调整为内网
将访问路径改为在服务器上需要访问的路径
Linux安装Jmeter
将Windows上的测试文件导入至Jmeter
在Linux上运行jmeter
将Linxu上的测试结果导出至Windows并用Jmeter打开测试结果
线程20 循环50
吞吐量为100以上,正常
为什么要在内网上进行Jmeter测试?
一般我们的性能测试都是在局域网中进行的。为什么一定要在局域网中进行呢?因为局域网中不受网络限制。这个说法不能绝对。但是一般测试工具的用户并发量是不会受到局域网带宽的限制,除非你做的是十万,百万级别的用户并发。相信懂一点网络知识的人都知道,当你上网很慢的时候,比如打开某某网站很慢,你肯定会骂电信的网络不给力,而不会骂这个网站响应速度不给力。因为,请求信息的耗时大部耗在传输过程中。
所以,刚做测试时,我们群里热议论,如果我们每个人都开一个压力工具对百度网站进行加压。百度,服务器会不会挂掉。有测友说这样是不道德人。呵呵!其实,完全不必有这个担心。就一般人家用的带宽,我确保,你向百度服务器发送的请求大部分都死在半路上,就算不死到了百度服务器已经不能叫并发了。何况百度服务器的集群技术以及其他各种分压技术。所以,做性能测试不了解被测系统的架构,以及各种技术的性能。很难做出有效的测试报告。
之前在网上找到关于memcached教程,虽然测试成功了,但是并不清楚具体的实现方法,然后就换了一种通过memcached工具类来实现
memcached工具类
package util;
import net.rubyeye.xmemcached.MemcachedClient;
import net.rubyeye.xmemcached.exception.MemcachedException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.TimeoutException;
public class MemcachedUtil {
private static final MemcachedClient memcachedClient;
private static final int EXP = 60*60; //seconds
static {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:memcached.xml");
memcachedClient = (MemcachedClient) applicationContext.getBean("memcachedClient");
}
/**
* 设置缓存数据
* @param key key
* @param value value
*/
public void set(String key,String value) throws InterruptedException, MemcachedException, TimeoutException {
memcachedClient.set(key, EXP,value);
}
public void set(String key,Object value) throws InterruptedException, MemcachedException, TimeoutException {
memcachedClient.set(key, EXP,value);
}
/**
*替换缓存数据
*/
public void replace(String key,String value) throws InterruptedException, MemcachedException, TimeoutException {
memcachedClient.replace(key, EXP,value);
}
/**
* 删除缓存数据
*/
public void delete(String key) throws InterruptedException, MemcachedException, TimeoutException {
memcachedClient.delete(key);
}
/**
* 获取缓存数据
* @param key
* @return Object
*/
public Object get(String key) throws InterruptedException, MemcachedException, TimeoutException {
return memcachedClient.get(key);
}
public Map<String,Object> get(Collection<String> keys) throws InterruptedException, MemcachedException, TimeoutException {
return memcachedClient.get(keys);
}
}
明天的计划,思考xmemcached的运行步骤,以及 应该写在service层的那个部分,怎么写
评论