简体   繁体   English

MySQL存储引擎的决定

[英]MySQL storage engine decision

I am a web designer from the Netherlands. 我是荷兰的网页设计师。 I am sort of new to building web apps from scratch, i have always used CMS, and customized them. 我从头开始构建Web应用程序,我总是使用CMS,并对其进行自定义。

I am building a Auction website in php/mysql, which is finished. 我正在php / mysql中建立一个拍卖网站,已经完成了。 Recently i read a few articles about storage engines. 最近我读了一些关于存储引擎的文章。

I have a few question that have been bothering me for a while now: 我有一些问题一直困扰着我一段时间:


What sort of storage engine is best suited for my website, do i use myIsam, innodb, etc. 什么样的存储引擎最适合我的网站,我使用myIsam,innodb等。

The website i am building is an auction website, it has to deal with several read and writes EVERY SECOND!! 我正在建设的网站是一个拍卖网站,它必须处理几个读写每一个! It has to check whether auctions are open, closed, paused, current price, etc. 它必须检查拍卖是开放,关闭,暂停,当前价格等。

I know not all tables in my database, will be accessed, these are only 3. They are currently all myIsam. 我知道不是我的数据库中的所有表都会被访问,这些表只有3个。它们目前都是myIsam。 Is this good? 这个好吗? should i change them all? 我应该改变它们吗? Change none? 没有改变? I really don't know what to do. 我真的不知道该怎么办。 Is i change them, will this impact my website drastically. 我是否会改变它们,这会对我的网站产生巨大影响。 And finnaly will these changes apply easily, or are they hard to do. 并且这些变化很容易适用,或者很难做到。


Another question i have is about Caching systems. 我的另一个问题是关于缓存系统。

I read a few about them too but i don't know if they apply to the sort of website i have. 我也读了一些关于它们但我不知道它们是否适用于我所拥有的那种网站。 The data i get out of the database changes a lot. 我从数据库中获取的数据发生了很大变化。 Is it handy for me to cache them? 缓存它们对我来说很方便吗? For example an auction can be cached, because not all items change. 例如,可以缓存拍卖,因为并非所有项目都会更改。 But the auction wont be there forever, after a few hours its gone. 但拍卖会不会永远存在,经过几个小时它就不见了。

I can't see how a cache system could apply to that, or am i seeing this the wrong way. 我无法看到缓存系统如何应用于此,或者我看到错误的方式。 And again, if this system applies to me, will this change take a lot of effort, and will this effort make a huge amount of change. 而且,如果这个系统适用于我,这种改变是否需要付出很多努力,而且这种努力会带来巨大的变化。


These are all the questions i have, they are really general i guess, i hope some people can help me with them, i would really appreciate that. 这些都是我的问题,我猜它们非常普遍,我希望有些人可以帮助我,我真的很感激。

Regards 问候

InnoDB InnoDB的

On a scenario like the one you are describing I would go with InnoDB without hesitating . 在你所描述的场景中,我会毫不犹豫地使用InnoDB Take a look at these that you probably are going to need: 看看你可能需要的这些:

  1. row level locking 行级锁定
  2. multi-statement transactions 多语句交易
  3. rollback 回滚

Caching 高速缓存

You've got several ways to do cache. 你有几种方法可以进行缓存。 But say your front-page gets 10 hits a second and changes every five minutes. 但是说你的头版每秒有10次点击并且每五分钟就会改变一次。 Makes perfect sense to store the front-page in a pure html file and have a cron-job update that page every five minutes. 将首页存储在纯html文件中并且每隔五分钟就有一个cron-job更新页面,这非常有意义。

What sort of storage engine is best suited for my website, do i use myIsam, innodb, etc. 什么样的存储引擎最适合我的网站,我使用myIsam,innodb等。

In general for any task default to InnoDB for its ACID-compliance and row-level locking. 通常,对于任何默认为InnoDB的任务,其ACID兼容性和行级锁定。 Consider resorting to MyISAM only for (a) fulltext search and (b) specific cases where performance under InnoDB isn't good enough (it's fairly rare that this is significant but some types of data can benefit from MyISAM's profile). 考虑仅针对(a)全文搜索以及(b)InnoDB下的性能不够好的特定情况(这种情况相当罕见,但是某些类型的数据可以从MyISAM的配置文件中受益)。

The website i am building is an auction website, 我正在建设的网站是一个拍卖网站,

A function like auctions really really needs a consistent transactional database behind it because you're talking about people's money. 像拍卖这样的功能真的需要一个一致的交易数据库,因为你在谈论人们的钱。 MyISAM can't offer that. MyISAM无法提供。 Your sites need to be using transactions for all non-atomic interactions, so that it's not possible for eg. 您的站点需要使用事务进行所有非原子交互,因此例如,它是不可能的。 two people to win the same auction when they bid at exactly the same time. 两个人在同一时间竞标时赢得同一场拍卖。

it has to deal with several read and writes EVERY SECOND!! 它必须处理几个读取和写入每一个!

That's not a huge amount. 这不是一个巨大的数额。 However, InnoDB also typically performs better in write-biased access to a large table due to MyISAM's unfortunate table-level locking. 但是,由于MyISAM不幸的表级锁定,InnoDB通常在对大型表的写入偏置访问方面表现更好。

I read a few about them too but i don't know if they apply to the sort of website i have. 我也读了一些关于它们但我不知道它们是否适用于我所拥有的那种网站。

Don't rush into it. 不要急于进去。 Some web authors seem to assume that memcache is going to be needed for any site to have decent performance but that really isn't the case. 一些网络作者似乎认为任何网站都需要使用memcache来获得不错的性能,但实际情况并非如此。 Any caching solution you apply will add complexity and potential failure points to deal with update times and now-outdated information. 您应用的任何缓存解决方案都会增加复杂性和潜在的故障点,以处理更新时间和现在过时的信息。

So don't resort to caching until you really need to. 所以在你真的需要之前不要求助于缓存。 If your common front-end pages habitually do complex, slow queries over the dataset then yes, having some sort of cache for that, whether that's in the database itself or an external solution like memcache, can improve speeds. 如果您的常见前端页面习惯性地对数据集进行复杂,缓慢的查询,那么就可以使用某种缓存,无论是数据库本身还是外部解决方案(如memcache),都可以提高速度。 But probably you'd actually be better off changing the schema and adding indexes to make that query cheaper than adding the complexity and inconsistency of a cache. 但实际上,你可能最好更改模式并添加索引,以使查询比添加缓存的复杂性和不一致性更便宜。

And on a site that's only doing “several” operations a second, you ain't gonna need it. 在一个只进行“几次”操作的网站上,你不会需要它。

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

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