duancan1950 2014-10-08 20:43
浏览 44

登录到文件系统或数据库?

I'm using LAMP and have full access to server configuration and setup.

I am very confused about which is the best method to simply log some data to.

I want to log things like this:

  • Analytics (server side with PHP) of every visitor.
  • When creating a new user, store id number so an email and SMS message can be sent later in a Cron Task (saves from sending the email/SMS during the users' request).
  • Number of page views of certain 'articles'. Increment once per visit to that page.

As you can see they are all simple insert/add actions that all can be processed later by a Cron Task.

The application needs to be scalable for the future.

These are my options (and what I have learned):

(1) Database (MySQL). People say don't use this for logging data like above.

(2) Use file_get_contents() WITHOUT a file lock. I'm told this can cause data corruption.

(3) Use file_get_contents() WITH a file lock but I believe this either results in missed data as file_get_contents returns false and doesn't add the data if the lock is in force -OR- it results in PHP having to wait for the lock to release. I don't think MySQL has to wait to do multiple inserts.

Which is the best option? Does it make a difference if I'm handling tens of requests per seconds compared to thousands of requests per second, or would I use the same option?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line