locked
Can Simultaneous Access Of Data Stored In Text File Cause Deadlock RRS feed

  • Question

  • User-1231523685 posted

    I have an application that allows users to create a web page based on the template that he/she chooses. I have lots of template data stored in JSON files which I plan to use to populate the body of a web page via AJAX call.

    I know that if I store the template data in a database I will not face the DeadLock issue as SQL server have built-in features to handle simultaneous data access. However, suppose I use JSON files to store the template data as I had planned, will simulatneous access of these files by multiple users cause a deadlock or a crash? 

    Wednesday, July 11, 2018 10:20 PM

All replies

  • User36583972 posted


    Hi gapi555,

    However, suppose I use JSON files to store the template data as I had planned, will simulatneous access of these files by multiple users cause a deadlock or a crash? 

    You can try to use the lock Statement (C# Reference)

    The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing the lock. The following example includes a lock statement.

    and Asynchronous programming with async and await (C#) in asp.net to avoid activities that are potentially blocking.

    Best Regards,

    Yong Lu

    Thursday, July 12, 2018 9:28 AM
  • User753101303 posted

    Hi,

    You shouldn't have any issue if you are just reading those template files. I would suggest to always start from what actually happens. You add ASPX files to your web app? It would cause the application to restart. Which kind of "crash" or "deadlock" behaviour do you see ???

    Monday, July 16, 2018 12:12 PM
  • User-1171043462 posted

    Database is always better than File. With File even if you use the best Lock mechanism. There will arise a case when you will have a corrupt file with two processes trying to access.

    Plus the operations you can do in DB will not be present in case of File.

    Monday, July 16, 2018 8:13 PM