用PHP编写的顶级内容系统

I want to write a top articles system.

I want to filter some content (articles/etc..) by number of views.

If I insert in database with views=views+1 every time when a user view that link, I think it's slowly and it's a bad practice.

An example of another site that does this is YouTube. It updates this table only at a certain interval, so the views aren't updated live. Is this a good practice to do this?

You could create a log (simple text file / xml / Json ………) to store the view count and do a job to parse the file and insert the result into the DB.

This job could run in time intervals or check the system for idle processor.

In my opinion, using the RAM to store sensitive data as this count (an important part of your system) seems kind of insecure.

Create a second table of views; you can also use this second table to filter "duplicate" views (backed too by cookies - removing duplicate views won't be a perfect operation).

As for being "slow" I've used that approach on many sites with many users. Storing and aggregating data is what databases do, so use their power.

Then you can use this second table to total the views, or periodically sum up the data and store the running total in the main table, clearing out the second table to keep space down. I usually keep all the data but demoralize for speed.