kestrel

.NET Core 3.1 的REST 和gRPC 性能测试

强颜欢笑 提交于 2020-04-14 00:22:51
【今日推荐】:为什么一到面试就懵逼!>>> 看到越南小哥 的github 上的 Evaluating Performance of REST vs. gRPC , 使用的是.NET Core 3.0 , 今天我把它升级到.NET Core 3.1 同样做了一个测试,文章的结果和他的博客文章是一样的: https://dev.to/thangchung/performance-benchmark-grpc-vs-rest-in-net-core-3-preview-8-45ak 。 在8年前我写过一篇文章: WCF和ASP.NET Web API在应用上的选择 。 现在是2020年了,WCF换成了gRPC, ASP.NET Web API换成了ASP.NET Core Web API, 对外提供标准化的REST服务,内部通信采用gRPC的也是新时代的.NET应用程序的一个好选择,类似于Kubernetes 架构将有效负载格式用于传输协议的方式。 我们来看下.NET Core 3.1下REST和gRPC的性能表现怎么样? 从 https://github.com/geffzhang/RESTvsGRPC 下载代码。在测试机器上安装.NET Core 3.1。 REST API: cd RESTvsGRPC\RestAPI dotnet run -p RestAPI.csproj -c

ASP.NET Core技术研究-探秘Host主机启动过程

三世轮回 提交于 2020-04-13 08:00:30
原文: ASP.NET Core技术研究-探秘Host主机启动过程 当我们将原有ASP.NET 应用程序升级迁移到ASP.NET Core之后,我们发现代码工程中多了两个类Program类和Startup类。 接下来我们详细探秘一下通用主机Host的启动过程。 一、Program类的Main函数入口 Program类最重要的功能就是 启动主机 ,这里有一个主机的概念,是ASP.NET Core全新引入的。 主机负责应用程序启动和生存期管理。 同时,主机也是封装应用程序资源的对象: 依赖注入 (DI) Logging Configuration IHostedService 实现 启动主机时,它在 DI 容器中找到 IHostedService 的每个实现,然后调用 IHostedService.StartAsync。 在 web 应用中,其中一个 IHostedService 的实现是 启动 HTTP 服务器实现的 web 服务 。这里的HTTP服务器默认是Kestrel。 即:ASP.NET Core主机启动时,会启动一个HTTP服务器,默认是Kestrel。启动后监听并响应某个端口的HTTP请求。 我们继续看Program类的代码: 从上述代码可以看到,Main函数中首先调用CreateHostBuilder方法,返回一个IHostBuilder

【转】Aspnet Core为什么支持跨平台

拥有回忆 提交于 2020-04-10 09:09:02
1.框架决定--因为代码运行需要环境,有了能够运行在 Windows和Linux下面的 CLR. 2.netCore有了个 kestrel(具体的解释去查询下).跨平台的适用于ASP.NET Core的WEB服务器。角色类似 IIS,他不是IIS, 简单的说 kestrel的性能高,功能少,在Linux下性能更高,不支持反向代理。 先来看一下.NET Framework和Core的大体结构 NET Framework本身是个"跨Windows"的平台, 而在这个基础上, 又支持C#和VB等语言进行 "跨语言", 这些语言都遵守CLS, 编译成CIL执行. 从我们多层架构设计的角度来看, 只换最底层, 还是很可行的. .NET Core 重做了一个CoreCLR的运行时,以及一个叫做CoreFX的BCL. 这里要说一下, ASP.NET Core 完全作为 NuGet 包的一部分提供。 这样一来,可以将应用优化为只包含必需 NuGet 包, 使应用更加灵活、模块化的同时提高性能. .NET Core通过实现.NET Standard与 .NET Framework做兼容. 至于跨平台, 因为90%的CoreFX代码都是与平台无关的 https://www.cnblogs.com/huaan011/p/12204883.html https://blog.csdn.net

ASP.NET Core 响应压缩中间件

家住魔仙堡 提交于 2020-03-02 05:01:30
使用及对比 在 Startup.cs 中添加服务并使用即可,主代码如下: // Startup.cs public void ConfigureServices(IServiceCollection services) { // ... services.AddResponseCompression(); // ... } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { // ... app.UseResponseCompression(); // ... } 未使用响应压缩中间件 新建一个 ASP.NET Core API 项目 运行并访问 响应头信息如下: Content-Type: application/json; charset=utf-8 Date: Fri, 06 Jul 2018 13:17:32 GMT Server: Kestrel Transfer-Encoding: chunked 使用响应压缩中间件 新建一个 ASP.NET Core API 项目 添加并配置 Microsoft.AspNetCore.ResponseCompression 响应压缩中间件 运行并访问 响应头信息如下: # gzip 压缩编码 Content-Encoding: gzip

How to stop outbound HTTP connections from timing out

旧巷老猫 提交于 2020-02-24 05:56:27
问题 Backgound: I'm currently hosting an ASP.NET application in Azure with the following specs: ASP .Net Core 2.2 Using Flurl for HTTP requests Kestrel Webserver Docker (Linux - mcr.microsoft.com/dotnet/core/aspnet:2.2 runtime) Azure App Service on P2V2 tier app service plan I have a a couple of background jobs that run on the service that makes a lot of outbound HTTP calls to a 3rd party service. Issue: Under a small load (approximately 1 call per 10 seconds), all requests are completed in under

How can I know when Kestrel has started listening?

假如想象 提交于 2020-01-22 14:59:25
问题 I need to notify systemd that my service has started up successfully, and a task it needs to run after startup requires that the server is already listening on the target Unix domain socket. I am using IWebHost::Run to start the server, and that is a blocking call. Additionally, I am unable to find any obvious way to set a delegate or callback event for successful initialization. Anyone? 回答1: On .Net Core 1.x it is safe to just run IWebHost.Start() and assume that the server is initialized

Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-10 17:18:28
问题 I am working on a fabric application where I have configured HTTPS. It is throwing an exception though I have a valid installed certificate. 回答1: These instructions from this blog worked for me dotnet dev-certs https --clean dotnet dev-certs https -t 回答2: I am on OSX and dotnet dev-certs https --clean and sudo dotnet dev-certs https --clean were not working for me. Finally I was able to fix it with the following steps. Go into Keychain Access Unlock System Keychain Delete the localhost

ASP .Net Core with Kestrel implement SSL

帅比萌擦擦* 提交于 2020-01-03 04:57:11
问题 i'm facing problem when implementing ssl to my web. My web work as web services for android and ios. All goes very smooth until i implement the SSL certificates, suddenly the android (most of android except samsung) throw this error : E/ErrorHTTP: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. then i google and landed to here : google says about the error support the google statement work around for the error to accept the not valid ssl it says

.NET Core Access Site Externally?

僤鯓⒐⒋嵵緔 提交于 2019-12-25 00:56:34
问题 When I start my .NET Core app in VS 2019 using Kestrel in debug mode I can only access as https:// localhost:5001 . When I try to replace localhost with my fqdn of my computer I get "Site cannot be reached". So actually it would be the computer and domain name so https:// win7.int.com:5001 . I want to do this so that I can access the site from a different machine. If it doesn't work on my own machine this way I doubt it would on another. Now ideally I would have several apps under this main

Kestrel server slow on “bad request data”

折月煮酒 提交于 2019-12-24 07:28:31
问题 I have an IOT device (black box, can't reprogram it) that sends http POST requests (136 bytes of JSON, a string) over wired ethernet to my .NET core 2.2 very simple server console application. I just output the string to the console. [HttpPost] public void Post([FromBody] RootObject root) { string adv = root.prt; Console.WriteLine(adv); } I get to display less than 1 line per second, sometimes 2. Using Fiddler as a reverse proxy, instead I receive between 5 and 10 http req per second, that is