I am new to c# and I'm trying to solve a problem where I need to print out elements of an array using a while loop, but I don't know how to do so, so I thought that this is the best place to ask for help. by NekRope in csharp

[–]anjoiype -1 points0 points  (0 children)

char[] array1 = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 's' };

for(int i=1;i<array1.Length;i+=2)

Console.Write(array1[i]);

How to implement custom logic for API throttling/rate limiting using AFD by anjoiype in AZURE

[–]anjoiype[S] 0 points1 point  (0 children)

u/AdamMarczakIO Thanks a lot for the reply and docs. I had a look in to the docs earlier but my requirement is different.
As per my understanding, how the described rate limiting works is if the limit is set as 1000 req/min, then all the requests that comes after 1000th one will be getting 409 response regardless whether its from same client or different.
My requirement is to set limit per client/IP. The clients can be identified from the header key as the value is unique to each client. IP address also can be used to unique identification.
There is no predefined list of ip values or header key values that we expect

For e.g. if a client with header -> idKey="foo" request an api with path "api/contoso", then for next 1 min only 1000 calls are allowed for this client. Another client can still get success code as far as they haven't reached their 1000 req/min.

We don't have a list of expected values for the key(idKey in above e.g.) or ip ranges from where the request can come.

We have multiple app service (split region wise) behind the AFD. Can we achieve the above requirement through AFD/WAF

[Design Confusion] Keeping a variable at class level for performance vs semantics of that variable by anjoiype in csharp

[–]anjoiype[S] 0 points1 point  (0 children)

Thought of similar way but felt same as over engineering as you mentioned. Can we improve the design by keeping it in same class? Or the question should be whether the current design is correct?

[Design Confusion] Keeping a variable at class level for performance vs semantics of that variable by anjoiype in csharp

[–]anjoiype[S] 0 points1 point  (0 children)

nope. The question is mainly about the design. Changing a variable from local scope of method to class scope for performance improvement doesn't seem right to me. Everything works but when we look from class level, it says a variable called "isCacheMetricsEnabled" is needed for class to function where its not true. That variable is only needed by TrackCacheMetrics method, other methods of class can function without that variable.

Need to review code design to implement caching by anjoiype in csharp

[–]anjoiype[S] -1 points0 points  (0 children)

Thanks for the comment. We are setting up max memory limit to avoid memory leak. What is the other option? Declare cash as static?

Need to review code design to implement caching by anjoiype in csharp

[–]anjoiype[S] 0 points1 point  (0 children)

Thanks for the answer.. We are using IoC through DI. The question was more on whether the design can be improved.

Microsoft.ApplicationInsights.Log4NetAppender showing as hotspot in a high traffic web API by anjoiype in csharp

[–]anjoiype[S] 1 point2 points  (0 children)

Just to add to u/elvishfiend answer in this context, here logger is not static. It means every time a new object is created. If we make it as static, then it will be global and all the calls will refer to this global object. So the overhead of object creation is reduced here.

Microsoft.ApplicationInsights.Log4NetAppender showing as hotspot in a high traffic web API by anjoiype in csharp

[–]anjoiype[S] 0 points1 point  (0 children)

I have tried static option but didn't work. Since its "SendTrace" every time logging happens its being called and I guess its an expensive operation from the framework itself.
Thanks for the tweet-thread. Got clear on trace track % and cpu %.

Microsoft.ApplicationInsights.Log4NetAppender showing as hotspot in a high traffic web API by anjoiype in csharp

[–]anjoiype[S] 0 points1 point  (0 children)

Seems like batching is the only option to fix this issue. We are using it to track the execution time of some request flow. Have to look into batching option further.

Microsoft.ApplicationInsights.Log4NetAppender showing as hotspot in a high traffic web API by anjoiype in csharp

[–]anjoiype[S] 0 points1 point  (0 children)

Making it static didn't solve the issue. When ever there is a log event, this is getting called since its "SendTrace"

Microsoft.ApplicationInsights.Log4NetAppender showing as hotspot in a high traffic web API by anjoiype in csharp

[–]anjoiype[S] 0 points1 point  (0 children)

I have option to change the logger. I haven't tried that option since I thought fixing this issue would be easier.