dtiopy6088 2013-09-23 19:54
浏览 45
已采纳

PHP中的非线程安全是否会对数据库CRUD产生影响?

I have read several articles and answers on SO. When it comes to database insert, delete, etc., does thread safety matter? Can something be inserted in the wrong record, for example? What exactly is going to get hosed up if I abandon "safety"?

I am using Windows 2008 R2, IIS 7.5.

  • 写回答

1条回答 默认 最新

  • dongxian8272 2013-09-23 20:29
    关注

    Dagon is correct - thread safety is critical for any operation.

    Can something be inserted in the wrong record, for example?

    There's two questions here:

    1) is PHP thread safe?

    2) what happens if it's not thread safe?

    In regard to the first question, the PHP core engine is thread safe and has been for a number of years. However a working PHP installation incorporates multiple extensions from various sources - and the guys who write PHP are not in a position to guarantee that someone else's code behaves as expected.

    In regard to the second question, yes if the code is running as lightweight processes and is not thread safe, then your data could get messed up - more likely it will just crash: and since (AFAIK) the threaded PHP only works with the IIS ISAPI module (leaving aside the threads PECL) that means it'll probably take out the whole IIS instance.

    But the question you need to answer BEFORE you consider any of these is whether there is any benefit to using ISAPI threads rather than fastCGI and PHP. Personally, I would avoid a Micorosft platform for reasons of performance, reliability, not to mention my own sanity - but I do sometimes get involved in fixing other peoples problems. However I've not seen any benchmarks showing that ISAPI has any performance advantage, which might explain why it's dropped as of version 5.3.0 (on Linux there is no performance benefit but a very small capacity improvement of around 5%).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我的数据无法存进链表里
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端