Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Performance: Database Update vs. Application variable

New Here ,
Oct 11, 2010 Oct 11, 2010

I am new to ColdFusion, so sorry if this has been covered before. I searched and couldn't find anything similar.

I am building an online Texas Hold'em poker application using ColdFusion and Flex. There are quite a few things that need to be stored on the server side that will be updated quite often and these objects will need to be accessed by multiple users. For example, think of something like the current pot between players on a table, or the current hand state (who's turn it is to check/bet/raise), or the current players in the hand. All of these things will be updated quite a few times per hand, and if you add to that that each of these will be different per table, it adds up quick.

Would it be better to store these things in the database or store them in an application variable? Or is there a better way that I am not thinking of? Is there any sort of metric to follow for these kinds of things?

TOPICS
Database access
743
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 11, 2010 Oct 11, 2010

You haven't provided enough information about your application's specific requirements to determine "which is better". Neither option is, by default, better than the other. Application and session variables tend to perform better, since they're in memory, but they consume memory (surprise!) and won't survive a server failure or restart. So, you have to determine what's more important in your application.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2010 Oct 11, 2010

That makes sense. I guess what I am looking for then, is what is a general number (or general idea, not actual number) of application variables that would be possible in a single server architecture? I have read that these are best used when not updated often, and the sort of things I would be using them for would be updated quite often (once every few seconds probably), but would be very simple values. Per table, I would probably have 3 or 4 application variables. So if I got up to 100 tables, that would be 300-400 application variables updated quite often. And every hand, these values would be reset to hold the values of the next hand. So server reset data loss really wouldn't be an issue here.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 11, 2010 Oct 11, 2010

I don't think you'll find a documented general number of application variables you can have on a single server. But I think you could get away with 400 variables without any trouble.

Where you might run into trouble, though, is when you have multiple concurrent requests trying to read and change these values. You'll have to ensure that you single-thread write access to these variables using CFLOCK.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 12, 2010 Oct 12, 2010
LATEST

If it's conceivable that more than one game will be taking place at the same time, using a db is probably a lot safer.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources