What happens when multiple clients try to write in same HDFS file at same time?

Free Online Certification Courses – Learn Today. Lead Tomorrow. Forums Apache Hadoop What happens when multiple clients try to write in same HDFS file at same time?

Viewing 2 reply threads
  • Author
    Posts
    • #5700
      DataFlair TeamDataFlair Team
      Spectator

      Can multiple clients write into an HDFS file concurrently?

    • #5701
      DataFlair TeamDataFlair Team
      Spectator

      No Multiple clients can’t write into same HDFS file concurrently. HDFS works on write once read multiple model. When a client comes to namenode to write to a file namenode provides lease or lock for that file to the current client.

      When some other client comes to write on the same file and asks for write permission, namenode will check whether the lease has been given to some other client or not. If yes, then it will reject the write request of the other client.

    • #5703
      DataFlair TeamDataFlair Team
      Spectator

      HDFS actually works on ‘write once read many’ model. It means that only one client can write a line at a time. Multiple clients can’t write into HDFS file at the similar time. When a client is granted a permission to write data on data node block, the block gets locked till the completion of a write operation. If some another client request to write on the same block of the same file then it is not permitted to do so. It has to wait until write lock is revoked on that data node.

      An advantage of is that we don’t have to bother with synchronization. Since we write only once, our reader is guaranteed that the data can’t be manipulated while they read. It also enables high throughput data access which simplifies data coherency issues.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.