2

WSFederationHttpBinding を使用するとパフォーマンスが非常に悪くなります。iis は 1 秒あたり 250 リクエストしか処理しません。

バインディング:

public class CustomFactoryActive : ServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            ServiceHost host = new ServiceHost(serviceType, baseAddresses);
            CommonConf.ConfigureServiceHost(host);


            string issuerAddress = ConfigManager.ActiveSTS;
            string issuerMexAddress = issuerAddress + "/mex";

            WSFederationHttpBinding wsFedBinding = new WSFederationHttpBinding();
            wsFedBinding.Security.Mode = WSFederationHttpSecurityMode.Message;
            wsFedBinding.ReliableSession.Enabled = false;

            wsFedBinding.MaxReceivedMessageSize = wsFedBinding.MaxBufferPoolSize = Constants.MaxFileSize;

            XmlDictionaryReaderQuotas quotas = wsFedBinding.ReaderQuotas;
            quotas.MaxArrayLength = quotas.MaxBytesPerRead = quotas.MaxStringContentLength =
                quotas.MaxNameTableCharCount = quotas.MaxDepth = (int)Constants.MaxFileSize;

            var messageSecurity = wsFedBinding.Security.Message;

            messageSecurity.IssuedTokenType = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1";
            messageSecurity.IssuedKeyType = SecurityKeyType.SymmetricKey;
            messageSecurity.EstablishSecurityContext = false;
            messageSecurity.NegotiateServiceCredential = false;

            messageSecurity.IssuerAddress = new EndpointAddress(new Uri(issuerAddress));
            messageSecurity.IssuerMetadataAddress = new EndpointAddress(new Uri(issuerMexAddress));


            WS2007HttpBinding ws2007HttpBinding = new WS2007HttpBinding(SecurityMode.TransportWithMessageCredential);
            var wsHttpSecurity = ws2007HttpBinding.Security;
            wsHttpSecurity.Message.ClientCredentialType = MessageCredentialType.UserName;//авторизация по логину и паролю
            wsHttpSecurity.Message.NegotiateServiceCredential = true;
            wsHttpSecurity.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default;

            messageSecurity.IssuerBinding = ws2007HttpBinding;

            ContractDescription contractDescription = ContractDescription.GetContract(typeof(ISignService));

            EndpointAddress endpointAddress = new EndpointAddress(baseAddresses[0]);
            ServiceEndpoint endpoint = new ServiceEndpoint(contractDescription, wsFedBinding, endpointAddress);
            host.Description.Endpoints.Add(endpoint);

            return host;
        }
    }

私の wcf テスト メソッドは何もしません。単に 1 バイトを返します。

しかし、WIF saml トークンを使用せずにメッセージ セキュリティで単純な WSHttpBinding を使用すると、約 . 毎秒 4000 リクエスト

なぜだか理解できない

4

5 に答える 5

6

WCF アーキテクチャで時間が費やされている場所の概要を確認するには、WCF トレースをセットアップして構成する必要があります。詳細については、 http://msdn.microsoft.com/en-us/library/ms733025.aspxを参照してください。

トレースを有効にしてリクエストを確認すると、(単一の呼び出し元が同じサービスを複数回呼び出すテスト環境で) STS が 1 回だけ呼び出され、その後の呼び出しにはキャッシュされたトークンが含まれていることがわかりますただし、すべての呼び出しでセキュリティで保護された接続が設定されるため、呼び出しごとにトークン (CPU 時間がかかります) が検証されます。あるいは、メソッド レベルでサービス ホストをプロファイリングすることで、これらすべてを検証することもできます。

于 2012-08-03T09:58:24.920 に答える
3

NegotiateServiceCredential = trueチャネルを開くときに複数のネットワーク ラウンド トリップを追加するケースを見ました。クライアントでサービス証明書を変更wsHttpSecurity.Message.NegotiateServiceCredentialして指定してみてください。false

于 2012-08-05T05:20:31.887 に答える
3

また、証明書の検証に時間がかかる可能性もあります。クライアントの動作を変更して、証明書の検証と失効をスキップすることができます。

//Client
var clientCredentialsBehavoir = behaviors.Find<FederatedClientCredentials>();
clientCredentialsBehavoir.ServiceCertificate.Authentication.CertificateValidationMode =                     X509CertificateValidationMode.None;
clientCredentialsBehavoir.ServiceCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck;

//The same can be done on the server
var serviceConfiguration = new ServiceConfiguration();
serviceConfiguration.CertificateValidationMode =   X509CertificateValidationMode.None;

これは本番環境では実行しないでください。

これも appconfig を介して行うことができます。

于 2012-08-07T07:06:56.457 に答える
3

セキュリティ トークンをエミュレートし (実際の STS は使用しないでください)、パフォーマンスがどのようになるかを確認します。その部分があなたのボトルネックだと思います。

于 2012-06-27T16:58:18.470 に答える
2

SAML トークンは暗号化されます - 構成によって異なります。あなたの場合、 を使用しているようですがSecurityAlgorithmSuite.Default、これは だと思いますAES256

復号化/暗号化が発生するたびに、CPU が数値計算を行うのに時間がかかります。かかる時間/労力はさまざまな要因によって異なりますが、リクエスト処理機能の違いが見られるのはそれほど珍しいことではないと思います。

他の回答で述べたように、トークンがキャッシュされている場合でも、トークンを検証して復号化する必要があり、そのたびに 1 つ以上のアルゴリズムを介してトークンの内容を実行する必要があります。

SecurityAlgorithmSuite私の推奨事項: さまざまな定数を使用してプロファイリングを実行し、結果を比較してください。

開始する場所の 1 つは、 との比較SecurityAlgorithmSuite.Basic128です.Basic256。定数は、256デフォルト オプションと同等です。

于 2012-08-09T23:14:08.550 に答える