Performance problem

Topics: General Topic
Jul 9, 2012 at 5:39 PM

I think i have a done mistake somewhere in my code. I try to compare the performance of NetSQLAzMan and AzMan. When I run this piece of code 100 times in netsqlAzMan, it takes 16 seconds to do it. Is it normal ?

for(int i = 0; i < 100; i++)       

{           

AuthorizationType auth = storage.CheckAccess(Constantes.STORE, Constantes.APPLICATION, Operation.TA_OP_1, identity, DateTime.Now, false, UA1);           

AuthorizationType auth2 = storage.CheckAccess(Constantes.STORE, Constantes.APPLICATION, Operation.TA_OP_2, identity, DateTime.Now, false, UA2);           

}

I'm sure i'm doing something wrong because in AzMan it takes 2 seconds to do the same operations. Can you help me ?

Jul 9, 2012 at 5:43 PM

Hi,

have you opened the SQL Connection (storage.OpenConnection) … before entering the for loop ?!

Otherwise … the connection is opened and closed everytime you make a single checkAccess.

__________________________________
Andrea Ferendeles
NetSqlAzMan Project Coordinator
E-mail aferende@hotmail.com Web http://netsqlazman.codeplex.com

Da: JFrancois [email removed]
Inviato: lunedì 9 luglio 2012 18:40
A: Andrea Ferendeles
Oggetto: Performance problem [netsqlazman:362560]

From: JFrancois

I think i have a done mistake somewhere in my code. I try to compare the performance of NetSQLAzMan and AzMan. When I run this piece of code 100 times in netsqlAzMan, it takes 16 seconds to do it. Is it normal ?

for(int i = 0; i < 100; i++)

{

AuthorizationType auth = storage.CheckAccess(Constantes.STORE, Constantes.APPLICATION, Operation.TA_OP_1, identity, DateTime.Now, false, UA1);

AuthorizationType auth2 = storage.CheckAccess(Constantes.STORE, Constantes.APPLICATION, Operation.TA_OP_2, identity, DateTime.Now, false, UA2);

}

I'm sure i'm doing something wrong because in AzMan it takes 2 seconds to do the same operations. Can you help me ?

Jul 9, 2012 at 5:50 PM

Yes i open it before the for loop and close it after.

Jul 9, 2012 at 5:51 PM

May be a SQL Server problem.

Try to inspect response time using the SQL Server Profiler utility.

__________________________________
Andrea Ferendeles
NetSqlAzMan Project Coordinator
E-mail aferende@hotmail.com Web http://netsqlazman.codeplex.com

Da: JFrancois [email removed]
Inviato: lunedì 9 luglio 2012 18:50
A: Andrea Ferendeles
Oggetto: Re: Performance problem [netsqlazman:362560]

From: JFrancois

Yes i open it before the for loop and close it after.

Jul 9, 2012 at 7:59 PM

Response time in sql server is great, the problem was about the bizrule I used. When I call my function with and empty Bizrule (return true), it takes 11 seconds to make the 100 iterations. If I have no bizrule at all, it takes 2.7 sec. Is there something I can do to speed the Bizrule ?

Jul 9, 2012 at 10:03 PM

If you are using a Biz Rule … may be.

Remember that every time a Biz Rule is invoked … NetSqlAzMan must extract the entire compiled DLL from a SQL binary field, create at run-time an instance and attach to the host process … then the Biz Rule must be invoked using Reflection.

Try to switch off the Biz Rule and watch again response time.

__________________________________
Andrea Ferendeles
NetSqlAzMan Project Coordinator
E-mail aferende@hotmail.com Web http://netsqlazman.codeplex.com

Da: JFrancois [email removed]
Inviato: lunedì 9 luglio 2012 21:00
A: Andrea Ferendeles
Oggetto: Re: Performance problem [netsqlazman:362560]

From: JFrancois

Response time in sql server is great, the problem was about the bizrule I used. When I call my function with and empty Bizrule (return true), it takes 11 seconds to make the 100 iterations. If I have no bizrule at all, it takes 2.7 sec. Is there something I can do to speed the Bizrule ?

Jul 10, 2012 at 3:25 AM

Maybe it's off topic but I'd like to share my experience with you. I have been using NetSqlAzMan for around 5 years. I started with Biz Rules also but later decided to create .Net DLLs instead. The reasons included performance and maintainability. Also, for web applications I always use cache. The performance improvement is dramatic. I have applications doing page/menu item/button/data row security. Without cache, the response time is terrible. With cache, it's lightning fast.

Richard

Jul 11, 2012 at 7:53 PM

Thanks for the answer Richard

Can you tell me how you implemented your .net dll on the checkAccess event, I see no event to do that in SQlAzManEs ?

Aferende yes, when I deactivate the Bizrule it goes a lot faster. I'm posting here my webconfig. Can you tell me if something is missing to make the cache service work ?

   <system.serviceModel>

    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_ICacheService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
            <message clientCredentialType="Windows"/>
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://localhost:8000/NetSqlAzMan.Cache.Service/CacheService/" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ICacheService" contract="NetSqlAzManWCFCacheService.ICacheService" name="NetTcpBinding_ICacheService">
        <identity>
          <userPrincipalName value="toto@toto.com"/>
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

Jul 12, 2012 at 9:08 PM

I don't know what kind of use cases you have. In my case, I don't need deal with events. My implementation is mainly an extension of CheckAccess method. For example, if I need determine authorization based on some attributes of NetSqlAzMan items/authorizations, I'll call CheckAccess method and get back the attributes. Then I'll go through the attributes to determine if the user is truly authorized. I even extended NetSqlAzManRoleProvider with the same idea.

Richard.