: When multiple users access the service at the same time?

Source: Internet
Author: User
: When multiple users access the service at the same time? Thank you for your advice!
The situation is described as follows:

System structure: 1. Interface Module (php) --> 2. Intermediate interface (php) --> 3. Database (mysql)
1. Interface Module: displays the operation interface and operation results;
2. Intermediate interface: responsible for data exchange between the interface module and the database, and other functions (not described for help issues );

General process: send an http request from the interface module. the request is sent to the interface module. the interface module accesses the database to obtain data and returns the data to the interface module;

Question:
The interface module has a large number of users, and these users may send the same request to the interface at the same time, for example, editing a certain data at the same time.

Q: How can this problem be avoided?

I do not know whether the description is clear. please kindly advise me. thank you!


Reply to discussion (solution)

Lock

If the business allows "editing a data at the same time", the last submission prevails.
Otherwise, xxx is being edited when receiving the request.

Thank you for your advice! Can I provide details? Partners require that only a certain data be edited at the same time in the interface module.

When user A successfully edited A News record, set the status field of the data to 1 to record the timestamp.
If someone wants to edit the file, status 1 is rejected.
User A's page ajax polling tells the server that the time is still being edited and refreshed every dozens of seconds.
When User A edits and submits, or User B wants to edit the status to 1, but the last ajax submission time is too different from the current one, the status is set to 0.

When user A successfully edited A News record, set the status field of the data to 1 to record the timestamp.
If someone wants to edit the file, status 1 is rejected.
User A's page ajax polling tells the server that the time is still being edited and refreshed every dozens of seconds.
When User A edits and submits, or User B wants to edit the status to 1, but the last ajax submission time is too different from the current one, the status is set to 0.



Thank you for your reply. I have some questions. can I do this in the interface module? I once asked a friend who has been working on php for many years and told me that this could not be done.
Previously, I also thought about setting identifiers because I could not operate the database, so I gave up.

Do you not need permissions during editing? Can I edit B sent by?

Do you not need permissions during editing? Can I edit B sent by?



Thank you for coming!
Permissions are required for editing, but multiple online users with permissions can edit a data entry.

The same record cannot be edited at the business layer.
The implementation of business requirements should be completed in the intermediate interface. If you have special requirements, you can also complete them in the interface module.
Your requirement should be completed in the intermediate interface

The same record cannot be edited at the business layer.
The implementation of business requirements should be completed in the intermediate interface. If you have special requirements, you can also complete them in the interface module.
Your requirement should be completed in the intermediate interface



Thank you for your comments! Thank you!
I did not describe the business logic in detail. I re-describe the business logic:
The functions of the interface layer include data display, data editing requests, and user management operations. the interface layer also contains databases for user operations.
Intermediate interface layer: process the request at the interface layer and ignore the operation user. no matter which operation user's operation request is processed, the intermediate interface layer is regarded as legal.

I think the moderator, you mean to process it at the intermediate interface layer, and then no matter who sends the request, the request comes over, the identity is locked, and the result is returned before the logo is unlocked?
I thought so before, because the first contact with php was a veteran, so I was not sure.

The other party has to ask me to process the service on the interface layer. I can use ajax, but I don't think I can set the id. so I am confused.

Thank you again for your advice!

Suitable for middle layer
Generally, the middle layer is the API
Adding a filter condition is relatively simple.

Of course, the interface layer can also be implemented, but the interface layer should not (cannot) directly access the data layer.
Therefore, you need to set up a cache mechanism separately. if the cache is not processed, no request will be sent to the intermediate layer.
You can use a queue that shares memory or databases or files.

Suitable for middle layer
Generally, the middle layer is the API
Adding a filter condition is relatively simple.

Of course, the interface layer can also be implemented, but the interface layer should not (cannot) directly access the data layer.
Therefore, you need to set up a cache mechanism separately. if the cache is not processed, no request will be sent to the intermediate layer.
You can use a queue that shares memory or databases or files.



Thank you very much. It's clear. thank you !!!
Close the post.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.