The YYYY–MM–DD format is the only method of writing a numeric date in Canada that allows unambiguous interpretation, and the only officially recommended format. The presence of the DD/MM/YY (international) and MM/DD/YY (American) formats often results in misinterpretation. Using these systems, the date 7 January 2016 could be written as either 07/01/16 or 01/07/16, which readers can also interpret as 1 July 2016 (or 1916); conversely, 2016-01-07 cannot be interpreted as another date.
In spite of its official status and broad usage, there is no binding legislation requiring the use of the YYYY–MM–DD format, and other date formats continue to appear in many contexts.
When a cookie is empty and corrupt, users may run into intermittent access issues to your website. IIS may record CryptographicException (The data is invalid) error to Event Viewer for this issue. Since the issue is intermittent, there may not be a need for immediate solution. However, a root cause analysis can provide valuable information and clues to prevent future occurrences.
Here is the key part of the error message from the Application container in Event Viewer:
Event code: 3005 Event message: An unhandled exception has occurred. Trust level: Full Process name: w3wp.exe Exception type: CryptographicException Exception message: The data is invalid. at System.Security.Cryptography.ProtectedData.Unprotect(Byte encryptedData, Byte optionalEntropy, DataProtectionScope scope) at System.IdentityModel.ProtectedDataCookieTransform.Decode(Byte encoded)
High CPU load is one of the most common issues web servers struggle with. There could be several root causes such as deadlocks, insufficient hardware, high traffic, poor coding. In this post, I will explain the reason and solution for a high CPU load caused by an object which is not thread-safe.
This issue may surface in many ways. One if them is -obviously- high resource utilization. You can monitor the resource usage in Task Manager, Resource Monitor or Performance Monitor.
Before we go further, let’s remember what the thread safety is:
Thread safety is a computer programming concept applicable in the context of multi-threaded programs. A piece of code is thread-safe if it only manipulates shared data structures in a manner that guarantees safe execution by multiple threads at the same time.
High CPU load in Performance Monitor and Event Viewer
The Performance Monitor chart below shows that the CPU load is around 80% (red solid line). It also demonstrates how the error count (brown dashed line) increases in parallel to request total (green dashed line).
This issue may appear as error or warning messages in Event Viewer that seems unrelated to CPU load at first sight. The message below is recorded in the System container of Event Viewer and it mentions unresponsive application pool which points out high CPU load issue.
Event ID: 5010 (Warning)
A process serving application pool “X” failed to respond to a ping. The process id was “1234”
Root cause of the high CPU load
As I mentioned in the beginning of the post, there could be a variety of reasons why a web server suffers from high CPU load. In this scenario, the reason is that using an instance of a non-thread-safe object multiple times. More specifically, using the same HttpClient instance from different threads increases the CPU usage.
In official documentation for HttpClient, it is recommended to use only one instance of this object:
HttpClient is intended to be instantiated once and re-used throughout the life of an application. Instantiating an HttpClient class for every request will exhaust the number of sockets available under heavy loads. This will result in SocketException errors.