为什么 wcf 客户端连接到服务时这么慢? [英] Why it's so slow when a wcf client connects to the service?

查看:92
本文介绍了为什么 wcf 客户端连接到服务时这么慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 WCF 服务时遇到了性能问题.

I met a performance issue when using the WCF service.

故事是这样的:

  1. 我编写了一个由控制台应用程序托管的自托管 WCF 服务;

  1. I wrote a self-hosted WCF service which is hosted by a console application;

我写了一个简单的客户端来使用服务;

I wrote a simple client to consume the service;

WCF 服务运行后,客户端需要 15 秒以上的时间来创建与服务的连接.

After the WCF service is running, it takes over 15 seconds for the client to create connection with the service.

WCF 服务非常简单,就像Hello World"一样.这正常吗?

The WCF service is extremely simple just something like "Hello World". Is this normal?

推荐答案

一种方法是添加您自己的 热身 脚本;在初始加载时调用您的服务的脚本.

One way could be to add your own warmup script; a script that calls your service on initial load.

虽然,这个回答可能对你有帮助,通常,第一次访问服务很慢,但连续访问会在一两秒内.

Though, this answer might help you, usually, the first access to the service is slow, but the consecutive accesses would be within a sec or two.

第一个慢响应与服务程序集的JIT编译有关;这意味着它是正常的.

The first slow response is related to the JIT compilation of the service assemblies; which means its normal.

或者,您可能希望个人资料应用程序.您也可能想查看这篇文章我回过头来写的.

Alternatively, you may want to Profile you app. Also you may would like to checkout this article that I wrote some time back.

这篇关于为什么 wcf 客户端连接到服务时这么慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆