星空网 > 软件开发 > ASP.net

Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

一、环境及工具

1、服务器

  • VirtualBox5.1.4 安装 Ubuntu Server 16.04 amd64
  • MySql Ver 14.14 Distrib 5.6.21
  • Jexus 5.8.1
  • nginx 1.10.0
  • dotnet core 1.0.0-preview2-003121
  • supervisor 3.2.1

2、开发环境

  • VS2015 + Update 3
  • DotNetCore.1.0.0-VS2015Tools.Preview2.0.1.exe

3、测试工具

  • HttpTest4Net:http://www.ikende.com/httptest

二、项目及代码

1、mysql 数据访问、ORM

  • MySql.Data.Core 7.0.4-IR-191
  • Dapper 1.50.2

2、数据库及表

  • 数据库:Test
  • 数据表:User 两个字段:Id,Name,数据4条
CREATE TABLE `User` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`Id`)) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;-- ------------------------------ Records of User-- ----------------------------INSERT INTO `User` VALUES ('1', 'LXY-1');INSERT INTO `User` VALUES ('2', 'LXY-2');INSERT INTO `User` VALUES ('3', 'LXY-3');INSERT INTO `User` VALUES ('5', 'LXY-5-New');

  • 项目,最简单的三层结构,实现增删改查(下载)

Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

如需使用项目,请修改数据库连接字符串,在 appsettings.json 文件里:

{  "Logging": {    "IncludeScopes": false,    "LogLevel": {      "Default": "Debug",      "System": "Information",      "Microsoft": "Information"    }  },  "ConnectionStrings": {    "TestDb": "server=192.168.2.117;Port=51889;userid=test8888;password=test8888;database=Test;SslMode=None;"  }}

项目使用ASP.NET CORE 自带的依赖注入,没有使用第三方的,Controller代码如下:

[Route("api/[controller]")]  public class UserController : Controller  {    readonly IUserBll _userBll;    public UserController(IUserBll userBll)    {      _userBll = userBll;    }    [HttpGet]    public IEnumerable<User> Get()    {      return _userBll.GetList();    }    [HttpGet("{name}")]    public User Get(string name)    {      return _userBll.Get(name);    }    [HttpPost]    public void Post([FromBody]User user)    {      if(user == null || string.IsNullOrEmpty(user.Name))      {        return;      }      _userBll.Add(user);    }    [HttpPut]    public void Put([FromBody]User user)    {      if (user == null || user.Id < 0 || string.IsNullOrEmpty(user.Name))      {        return;      }      _userBll.Update(user);    }    [HttpDelete("{id}")]    public void Delete(int id)    {      _userBll.Delete(id);    }  }

三、ASP.NET CORE 在 Ubuntu 的配置

  参考大神 savorboard 的博客:http://www.cnblogs.com/savorboard。

四、测试结果

   说明:因为使用jexus端口转发模式测试时,Requests:10000   Users:50  KeepAlive:False 的时候,就出现了很多错误连接,所以没有继续测试,不知道是不是我的配置有问题,配置如下:

####################### Web Site: Default########################################port=8080root=/ /hoem/vsftpd/website/webapitesthosts=*  #OR your.com,*.your.com# addr=0.0.0.0# CheckQuery=false NoLog=true AppHost.Port=5000# NoFile=/index.aspx# Keep_Alive=false# UseGZIP=false# UseHttps=true# DenyFrom=192.168.0.233, 192.168.1.*, 192.168.2.0/24# AllowFrom=192.168.*.*# DenyDirs=~/cgi, ~/upfiles# indexes=myindex.aspx# rewrite=^/.+?\.(asp|php|cgi|pl|sh)$ /index.aspx

  端口转发测试结果如下:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  下面是 nginx 和 jexus 反向代理模式下的测试结果:

  1. Requests:10000; Users:50;KeppAlive:False

  nginx:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  jexus: 

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  2. Requests:10000; Users:50;KeppAlive:True

  nginx:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  jexus:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  3. Requests:10000; Users:200;KeppAlive:False

  nginx:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  jexus:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  4. Requests:10000; Users:200;KeppAlive:True

  nginx:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  jexus:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  5. Requests:10000; Users:500;KeppAlive:False

  nginx:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  jexus:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  6. Requests:10000; Users:500;KeppAlive:True

  nginx:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  jexus:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

   Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  7. Requests:10000; Users:100;KeppAlive:False

  nginx:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  jexus:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  8. Requests:10000; Users:1000;KeppAlive:True

  nginx:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  jexus:

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

  Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

 

五、总结

  1. 测试环境非常简陋,测试到1000用户的时候,路由器受不了了,其他应用程序都纷纷离线了,包括QQ。上面结果可能不是非常准确,但是有一定的参考价值。
  2. 只测试了GET,没有测试POST。
  3. 感觉ASP.NET CORE 应该慢慢的可以使用到生产环境中了:)。



原标题:Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试

关键词:ASP.NET

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

英国再现新型变异病毒!多佛港混乱下的“黑色圣诞”:https://www.ikjzd.com/articles/138381
50+ 垂直品类独立站后台真实销量数据大揭秘:https://www.ikjzd.com/articles/138382
通关攻略|规范申报常见错误:https://www.ikjzd.com/articles/138383
比糟糕更糟糕!英国惊现更强变异病毒,我国已暂停中英往返航班!:https://www.ikjzd.com/articles/138384
圣诞小高峰,平安夜大批卖家零单?!:https://www.ikjzd.com/articles/138385
2021年后疫情下小B客户开发之德国休闲包选品分析:https://www.ikjzd.com/articles/138386
十月北方旅游最佳去处?:https://www.vstour.cn/a/365184.html
缅甸电子签证口岸 缅甸电子签证在线申请:https://www.vstour.cn/a/365185.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流