68

高速开车换底盘记:Windows 与 Linux 部署都抗住了,但修车任务艰巨团队

 4 years ago
source link: https://www.cnblogs.com/cmt/p/11362531.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

高速开车换底盘记:Windows 与 Linux 部署都抗住了,但修车任务艰巨

抱歉,又是一篇流水账,在排查问题的焦头烂额中写博客的确是一个挑战,望大家见谅。

今天园友溪源More发了一篇博文博客园翻车启示录,而翻车之后的最新进展是——昨天下午我们又把 .net core 引擎的博客越野车开上了高速,现在依然行驶在高速上,今天上午我们边开车边给车换了个底盘,把 windows 换成了 linux(见页脚"Powered by .NET Core 3.0 Preview 8 on Linux"),从中发现虽然车勉强能开,但修车任务艰巨。

流水账开始。

昨天下午,部署在 windows 上的 .net core 版博客站点成功扛过了访问高峰,当时用了7台4核8G服务器,与 .net framework 版使用的服务器数量一样。

由于在 windows 上发布太麻烦了,不仅要复制所要发布的文件,还要停止 IIS 站点才能复制,不然会出现下面的错误提示,这点比不上 .net framework 。

cp: cannot create regular file '/c/websites/www.cnblogs.com-v2/Mapster.dll': Device or resource busy

于是,昨天晚上我们就准备 linux 上的 docker-compose 部署,并进行了试发布,将1台部署好的 linux 服务器加入了线上的负载均衡。

docker-compose pull
docker-compose down --remove-orphans
docker-compose --compatibility up --force-recreate -d 

之后出现的异常情况让我们不敢自己的双眼,数据库服务器 CPU 100% 的问题在 Linux 上没有使用 DbContextPool 的情况下昔日重来了。

35695-20190816112051331-756899806.png
2019-08-15 21:00:15.320 [Error] Failed executing DbCommand ("30,360"ms) [Parameters=["..."], CommandType='Text', CommandTimeout='30']"
...
Microsoft.EntityFrameworkCore.Database.Command
2019-08-15 21:00:15.321 [Error] An exception occurred while iterating over the results of a query for context type '"EfUnitOfWork"'.
System.Data.SqlClient.SqlException (0x80131904): Timeout expired.  
The timeout period elapsed prior to completion of the operation or the server is not responding.
 ---> System.ComponentModel.Win32Exception (258): Unknown error 258
   at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__126_0(Task`1 result)

在残酷的事实面前,我们不得不承认我们错怪了 DbContextPool ,这个诡异的问题是在某种未知的情况下偶然触发的,昨天我们去掉 DbContextPool 后没有出现问题,只是因为没有触发。

今天上午,我们将 docker-compose 部署 .NET Core 站点的 linux 服务器逐步上线了,在 11:00 左右全部换成了 linux 服务器,一共用了 6 台服务器,扛过了上午的访问高峰。.net framework 版博客用的也是 6 台服务器,所以我们就默认部署了 6 台,linux 上的 .net core 版博客究竟多少台服务器可以撑住,我们还没有验证过。

其中 1 台 linux 服务器的 CPU 占用情况如下:

35695-20190816120828385-286538649.png

今天早上还发现了 Windows 服务器的一个异常情况,一夜之后,8G的内存几乎被消耗殆尽,之前用 .net framework 版从来没有出现过的问题,不知是昨天夜里 .net core GC 偷懒了,还是我们写的代码存在内存泄露问题?

35695-20190816121033732-384167058.png

35695-20190816121129328-9995527.png

流水账就写到这。

接下来我们最艰巨的修车任务是排查数据库服务器 CPU 100% 的诡异问题。

Powered by .NET Core 系列博文:


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK