Jmeter Address already in use错误 windows本身提供的端口 tcp/ip为1024到5000,并且要四分钟来循环回收,导致我们在短时间跑大量的请求把端口占满了
Jmeter Address already in use错误
windows本身提供的端口
tcp/ip为1024到5000,并且要四分钟来循环回收,导致我们在短时间跑大量的请求把端口占满了
影响性能的点包括: 数据库,应用程序,中间件,网络和操作系统 还需要考虑应用是cpu密集型还是io密集型
影响性能的点包括:
数据库,应用程序,中间件,网络和操作系统
还需要考虑应用是cpu密集型还是io密集型
性能测试
测试内容线程数量吞吐量/S90%响应时间99%响应时间Nginx5098847102Gateway5028511092简单服务503798781Gateway简单服务50345115129
中间件越多,性能损失越大,网络IO和磁盘IO会大量吃掉性能
什么数据适合放入缓存 及时性,数据一致性要求不高的数据 访问量大且更新频率不高的数据(读多写少的数据)
什么数据适合放入缓存
及时性,数据一致性要求不高的数据
访问量大且更新频率不高的数据(读多写少的数据)
package com.alatus.mall.product.service.impl; import com.alatus.mall.product.service.CategoryBrandRelationService; import com.alatus.mall.product.vo.SubCatalogVo; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.alatus.common.utils.PageUtils; import com.alatus.common.utils.Query; import com.alatus.mall.product.dao.CategoryDao; import com.alatus.mall.product.entity.CategoryEntity; import com.alatus.mall.product.service.CategoryService; import org.springframework.transaction.annotation.Transactional; @Service("categoryService") public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity> implements CategoryService { @Autowired private CategoryBrandRelationService categoryBrandRelationService; @Override public PageUtils queryPage(Map<String, Object> params) { IPage<CategoryEntity> page = this.page( new Query<CategoryEntity>().getPage(params), new QueryWrapper<CategoryEntity>() ); return new PageUtils(page); } @Override public List<CategoryEntity> listWithTree() { // 查出所有分类 List<CategoryEntity> entities = baseMapper.selectList(null); // 组装父子的树形结构 // 找到一级分类 List<CategoryEntity> levelMenuOne = entities.stream().filter(categoryEntity -> categoryEntity.getParentCid() == 0 ).map((menu) -> { menu.setChildren(getChildren(menu,entities)); return menu; }).sorted((menu1,menu2) -> { return (menu1.getSort()==null?0:menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort()); }).collect(Collectors.toList()); return levelMenuOne; } @Override public void removeMenuByIds(List<Long> list) { // 检查当前删除的菜单,是否被别的地方引用 baseMapper.deleteBatchIds(list); } @Override public Long[] findCatelogPath(Long catelogId) { List<Long> paths = new ArrayList<>(); List<Long> parentPath = findParent(catelogId, paths); Collections.reverse(parentPath); return (Long[])parentPath.toArray(new Long[parentPath.size()]); } // 级联更新所有数据 @Override @Transactional public void updateCascade(CategoryEntity category) { this.updateById(category); categoryBrandRelationService.updateCategory(category.getCatId(),category.getName()); } @Override public List<CategoryEntity> getLevelCategories(Integer catLevel) { return baseMapper.selectList(new QueryWrapper<CategoryEntity>().eq("cat_level", catLevel)); } @Override public Map<String, List<SubCatalogVo>> getCatalogJson() { List<CategoryEntity> categories = baseMapper.selectList(null); // 所有一级分类 List<CategoryEntity> levelCategories = getParentCid(categories,0L);; // 封装数据 Map<String, List<SubCatalogVo>> subCatalogVosMap = levelCategories.stream().collect(Collectors.toMap(k -> k.getCatId().toString(),v -> { List<CategoryEntity> entities = getParentCid(categories,v.getCatId()); List<SubCatalogVo> subCatalogVos = null; if(entities!=null&&!entities.isEmpty()){ subCatalogVos = entities.stream().map(item -> { // 找三级分类 List<CategoryEntity> inCategories = getParentCid(categories,item.getCatId()); SubCatalogVo subCatalogVo = new SubCatalogVo(v.getCatId().toString(),null, item.getCatId().toString(), item.getName()); if(inCategories!=null&&!inCategories.isEmpty()){ // 封装成指定格式 List<SubCatalogVo.InCatalogVo> inCatalogVos = inCategories.stream().map(inCategory -> { SubCatalogVo.InCatalogVo inCatalogVo = new SubCatalogVo.InCatalogVo(item.getCatId().toString(),inCategory.getCatId().toString(),inCategory.getName()); return inCatalogVo; }).collect(Collectors.toList()); subCatalogVo.setCatalog3List(inCatalogVos); } return subCatalogVo; }).collect(Collectors.toList()); } return subCatalogVos; })); return subCatalogVosMap; } private List<CategoryEntity> getParentCid(List<CategoryEntity> categories,Long catId) { return categories.stream().filter(item -> item.getParentCid() == catId).collect(Collectors.toList()); } private List<Long> findParent(Long catelogId,List<Long> paths){ // 查出当前分类的ID // 收集当前节点ID paths.add(catelogId); CategoryEntity id = this.getById(catelogId); if(id.getParentCid() != 0){ // 递归查找,每次都从父节点获取 findParent(id.getParentCid(),paths); } return paths; } // 递归查找所有菜单的子菜单 private List<CategoryEntity> getChildren(CategoryEntity root,List<CategoryEntity> all){ List<CategoryEntity> children = all.stream().filter(categoryEntity -> { return categoryEntity.getParentCid() == root.getCatId(); }).map(categoryEntity -> { categoryEntity.setChildren(getChildren(categoryEntity,all)); return categoryEntity; }).sorted((menu1,menu2) ->{ return (menu1.getSort()==null?0:menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort()); }).collect(Collectors.toList()); return children; } }
package com.alatus.mall.product.service.impl; import com.alatus.mall.product.service.CategoryBrandRelationService; import com.alatus.mall.product.vo.SubCatalogVo; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.alatus.common.utils.PageUtils; import com.alatus.common.utils.Query; import com.alatus.mall.product.dao.CategoryDao; import com.alatus.mall.product.entity.CategoryEntity; import com.alatus.mall.product.service.CategoryService; import org.springframework.transaction.annotation.Transactional; @Service("categoryService") public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity> implements CategoryService { @Autowired private CategoryBrandRelationService categoryBrandRelationService; @Override public PageUtils queryPage(Map<String, Object> params) { IPage<CategoryEntity> page = this.page( new Query<CategoryEntity>().getPage(params), new QueryWrapper<CategoryEntity>() ); return new PageUtils(page); } @Override public List<CategoryEntity> listWithTree() { // 查出所有分类 List<CategoryEntity> entities = baseMapper.selectList(null); // 组装父子的树形结构 // 找到一级分类 List<CategoryEntity> levelMenuOne = entities.stream().filter(categoryEntity -> categoryEntity.getParentCid() == 0 ).map((menu) -> { menu.setChildren(getChildren(menu,entities)); return menu; }).sorted((menu1,menu2) -> { return (menu1.getSort()==null?0:menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort()); }).collect(Collectors.toList()); return levelMenuOne; } @Override public void removeMenuByIds(List<Long> list) { // 检查当前删除的菜单,是否被别的地方引用 baseMapper.deleteBatchIds(list); } @Override public Long[] findCatelogPath(Long catelogId) { List<Long> paths = new ArrayList<>(); List<Long> parentPath = findParent(catelogId, paths); Collections.reverse(parentPath); return (Long[])parentPath.toArray(new Long[parentPath.size()]); } // 级联更新所有数据 @Override @Transactional public void updateCascade(CategoryEntity category) { this.updateById(category); categoryBrandRelationService.updateCategory(category.getCatId(),category.getName()); } @Override public List<CategoryEntity> getLevelCategories(Integer catLevel) { return baseMapper.selectList(new QueryWrapper<CategoryEntity>().eq("cat_level", catLevel)); } @Override public Map<String, List<SubCatalogVo>> getCatalogJson() { List<CategoryEntity> categories = baseMapper.selectList(null); // 所有一级分类 List<CategoryEntity> levelCategories = getParentCid(categories,0L);; // 封装数据 Map<String, List<SubCatalogVo>> subCatalogVosMap = levelCategories.stream().collect(Collectors.toMap(k -> k.getCatId().toString(),v -> { List<CategoryEntity> entities = getParentCid(categories,v.getCatId()); List<SubCatalogVo> subCatalogVos = null; if(entities!=null&&!entities.isEmpty()){ subCatalogVos = entities.stream().map(item -> { // 找三级分类 List<CategoryEntity> inCategories = getParentCid(categories,item.getCatId()); SubCatalogVo subCatalogVo = new SubCatalogVo(v.getCatId().toString(),null, item.getCatId().toString(), item.getName()); if(inCategories!=null&&!inCategories.isEmpty()){ // 封装成指定格式 List<SubCatalogVo.InCatalogVo> inCatalogVos = inCategories.stream().map(inCategory -> { SubCatalogVo.InCatalogVo inCatalogVo = new SubCatalogVo.InCatalogVo(item.getCatId().toString(),inCategory.getCatId().toString(),inCategory.getName()); return inCatalogVo; }).collect(Collectors.toList()); subCatalogVo.setCatalog3List(inCatalogVos); } return subCatalogVo; }).collect(Collectors.toList()); } return subCatalogVos; })); return subCatalogVosMap; } private List<CategoryEntity> getParentCid(List<CategoryEntity> categories,Long catId) { return categories.stream().filter(item -> item.getParentCid() == catId).collect(Collectors.toList()); } private List<Long> findParent(Long catelogId,List<Long> paths){ // 查出当前分类的ID // 收集当前节点ID paths.add(catelogId); CategoryEntity id = this.getById(catelogId); if(id.getParentCid() != 0){ // 递归查找,每次都从父节点获取 findParent(id.getParentCid(),paths); } return paths; } // 递归查找所有菜单的子菜单 private List<CategoryEntity> getChildren(CategoryEntity root,List<CategoryEntity> all){ List<CategoryEntity> children = all.stream().filter(categoryEntity -> { return categoryEntity.getParentCid() == root.getCatId(); }).map(categoryEntity -> { categoryEntity.setChildren(getChildren(categoryEntity,all)); return categoryEntity; }).sorted((menu1,menu2) ->{ return (menu1.getSort()==null?0:menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort()); }).collect(Collectors.toList()); return children; } }
版权归原作者 旧约Alatus 所有, 如有侵权,请联系我们删除。