0

As the title says, could someone explain to me why WCF HttpsTransport using Websocket (transportUsage=Always), are faster than not using Websocket (transportUsage=Never) even when doing sessionless request-replies? My thinking was that not using Websockets in such case would be faster since we don't use a persistent connection and doing multiple short lived Websocket connect\disconnect are expensive. When I run our app though, the database lookups (using WCF) is slightly faster when transportUsage=Always that when Never. Using WCF tracing I can see the durations when transportUsage=Never are maybe 3x the durations when Always. Everything works with either setting but I don't understand why "Always" is faster even when using the websockets "incorrectly" such as in our case?

I was expecting HttpsTransport with transportUsage=Never to be faster in our case since we use the Websocket in a "sessionless" way.

1 Answers1

0

As far as I know, websocket is used in wcf scenarios where duplex communication is used. As you mentioned, the connection or disconnection will cost resources, and I think it will also affect efficiency.

Jiayao
  • 510
  • 3
  • 7
  • Yes, for duplex. But in my case we are using them for simple request-reply, essentially as when doing REST. Each request-reply is a full new websocket connect\disconnect sequence which is costly. Still the HttpsTransport is faster having them enabled than not and I don't understand why. – saibot75 Nov 18 '22 at 06:28
  • This may be the principle involved. I'm not sure. I think it takes more resources and time to turn on and off the link when needed, just like turning on and off the light in life. It's better to choose `always`. Hope it helps. – Jiayao Nov 22 '22 at 03:08