简体   繁体   English

避免对数据库PHP和MYSQLI进行多次更新

[英]avoid multi updates to database PHP&MYSQLI

I have a site , on my site every time that someone is clicking on a banner i am doing a select query to take all the relevant links so today i have about 1000000 clicks a day on links , this process is making too many querys on the server what other options do i have ? 我有一个网站,在我的网站上,每当有人点击横幅我正在做一个选择查询以获取所有相关链接,所以今天我每天有大约1000000次点击链接,这个过程在网上做了太多的查询服务器我还有其他选择吗?

i was thinking about using 我正在考虑使用

memcache 

and than to ask the server cache for the hosted link and every 5 minutes 而不是每隔5分钟向服务器缓存询问托管链接

i will run a 我会跑一个

CronJob 

that will give me the link. 这会给我链接。

there is any other kind of technologies i can use ? 我还可以使用其他任何技术吗?

memcache is a safe technology to use ? memcache是​​一种安全的技术吗?

I'm sure this is a large open-ended topic that doesn't have one particular answer. 我确信这是一个没有特定答案的大型开放式主题。 But if you are asking if people use memcache to take the load off the database server? 但是,如果你问人们是否使用memcachememcache数据库服务器的负担?

Certainly yes. 当然可以。 memcached is more than a decade old now; memcached现在已经十多年了; been tested and used by a lot many more companies. 已经过更多公司的测试和使用。

You could figure out the most frequent queries that your database server is getting and then start by caching the result set into memcache (and update your memcached whenever database inserts, updates & deletions occur). 您可以找出数据库服务器获得的最常见查询,然后通过将结果集缓存到memcache (并在发生数据库插入,更新和删除时更新memcached)。

You'd also observe that memcached is also frequently compared to redis . 您还会发现memcached也经常与redis进行比较。

There are several techniques that you can use to take off the load on your database. 有几种技术可用于卸载数据库的负载。 Please check out the answers here[1] 请在这里查看答案[1]

[1] https://softwareengineering.stackexchange.com/questions/60225/how-do-you-off-load-work-from-the-database [1] https://softwareengineering.stackexchange.com/questions/60225/how-do-you-off-load-work-from-the-database

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM