启用WCF压缩提升Dynamics 365 CE的网络性能

摘要: 微软动态CRM专家罗勇 ,回复307或者20190308可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me 。

本文系根据微软MSDN 博客的博文 Enable WCF Compression to Improve CRM 2011 Network Performance 而写,当时文章是针对Dynamics CRM 2011而写,那么针对Dynamics 365 Customer Engagement适合吗?我这里用我自己的 9.0.2.3034 版本来尝试下。

调用的程序很简单,就是C#写了一个控制台程序,使用组织服务执行FetchXml获取数据,当然我用Fiddler进行了抓包。

设置前用WCF压缩前的第一次抓包数据如下:

Request Count: 1
Bytes Sent: 12,864 (headers:250; body:12,614)
Bytes Received: 11,557 (headers:273; body:11,284)

ACTUAL PERFORMANCE
--------------
ClientConnected: 13:49:12.376
ClientBeginRequest: 13:49:13.035
GotRequestHeaders: 13:49:13.035
ClientDoneRequest: 13:49:13.386
Determine Gateway: 0ms
DNS Lookup: 0ms
TCP/IP Connect: 0ms
HTTPS Handshake: 0ms
ServerConnected: 13:49:12.768
FiddlerBeginRequest: 13:49:13.387
ServerGotRequest: 13:49:13.388
ServerBeginResponse: 13:49:13.697
GotResponseHeaders: 13:49:13.697
ServerDoneResponse: 13:49:13.697
ClientBeginResponse: 13:49:13.697
ClientDoneResponse: 13:49:13.698

Overall Elapsed: 0:00:00.663

RESPONSE BYTES (by Content-Type)
--------------
application/soap+xml: 11,284
~headers~: 273

设置启用WCF压缩前的第二次抓包数据如下:

Request Count: 1
Bytes Sent: 12,908 (headers:250; body:12,658)
Bytes Received: 11,557 (headers:273; body:11,284)

扫描二维码关注公众号,回复: 5463605 查看本文章

ACTUAL PERFORMANCE
--------------
ClientConnected: 13:49:47.303
ClientBeginRequest: 13:49:47.752
GotRequestHeaders: 13:49:47.752
ClientDoneRequest: 13:49:48.103
Determine Gateway: 0ms
DNS Lookup: 0ms
TCP/IP Connect: 0ms
HTTPS Handshake: 0ms
ServerConnected: 13:49:47.497
FiddlerBeginRequest: 13:49:48.104
ServerGotRequest: 13:49:48.105
ServerBeginResponse: 13:49:48.287
GotResponseHeaders: 13:49:48.305
ServerDoneResponse: 13:49:48.305
ClientBeginResponse: 13:49:48.305
ClientDoneResponse: 13:49:48.309

Overall Elapsed: 0:00:00.557

RESPONSE BYTES (by Content-Type)
--------------
application/soap+xml: 11,284
~headers~: 273

然后我用文中介绍的执行命令的方法来更改,以管理员身份打开 cmd ,执行如下命令:

%SYSTEMROOT%/system32/inetsrv/appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/soap+xml; charset=utf-8',enabled='true']" /commit:apphost

再执行下IISRESET命令以便更改生效,再次测试。

设置启用WCF压缩后的第一次抓包数据如下:

Request Count: 1
Bytes Sent: 12,864 (headers:250; body:12,614)
Bytes Received: 1,699 (headers:319; body:1,380)

ACTUAL PERFORMANCE
--------------
ClientConnected: 14:05:21.045
ClientBeginRequest: 14:05:26.227
GotRequestHeaders: 14:05:26.227
ClientDoneRequest: 14:05:26.577
Determine Gateway: 0ms
DNS Lookup: 0ms
TCP/IP Connect: 0ms
HTTPS Handshake: 0ms
ServerConnected: 14:05:26.009
FiddlerBeginRequest: 14:05:26.577
ServerGotRequest: 14:05:26.578
ServerBeginResponse: 14:05:26.870
GotResponseHeaders: 14:05:26.870
ServerDoneResponse: 14:05:26.870
ClientBeginResponse: 14:05:26.870
ClientDoneResponse: 14:05:26.871

Overall Elapsed: 0:00:00.643

RESPONSE BYTES (by Content-Type)
--------------
application/soap+xml: 1,380
~headers~: 319

设置启用WCF压缩后的第二次抓包数据如下:

Request Count: 1
Bytes Sent: 12,864 (headers:250; body:12,614)
Bytes Received: 1,700 (headers:319; body:1,381)

ACTUAL PERFORMANCE
--------------
ClientConnected: 14:06:46.012
ClientBeginRequest: 14:06:46.474
GotRequestHeaders: 14:06:46.474
ClientDoneRequest: 14:06:46.825
Determine Gateway: 0ms
DNS Lookup: 0ms
TCP/IP Connect: 0ms
HTTPS Handshake: 0ms
ServerConnected: 14:06:46.208
FiddlerBeginRequest: 14:06:46.825
ServerGotRequest: 14:06:46.826
ServerBeginResponse: 14:06:47.025
GotResponseHeaders: 14:06:47.025
ServerDoneResponse: 14:06:47.025
ClientBeginResponse: 14:06:47.025
ClientDoneResponse: 14:06:47.026

Overall Elapsed: 0:00:00.551

RESPONSE BYTES (by Content-Type)
--------------
application/soap+xml: 1,381
~headers~: 319

可以看到的是,压缩比非常高,启用之前客户端收到的字节数在 11,557左右,启用压缩后收到的字节数是 1,700,只有原来的 14.7%左右,压缩比很高。

再来看下从ServerConnected到ClientDoneResponse的时间,四次分别花了:930ms, 812ms, 862ms, 818ms,  Overall Ellapsed四次分别花了 663ms, 557ms, 643ms,  551ms,有点儿差别,但是不大。

启用了WCF压缩后有个值得注意的地方就是要观察服务器CPU的利用率,因为是动态内容,每次都要压缩。

猜你喜欢

转载自www.cnblogs.com/luoyong0201/p/Dynamics_365_Enable_WCF_Compression_Improve_Network_Performance.html
365