BitCoinDream
Legendary
Offline
Activity: 2394
Merit: 1216
The revolution will be digital
|
|
September 25, 2014, 03:24:29 PM |
|
Committing 10k rolls at a time may go against the atomic consistency of the DB resulting in unexpected effect to the bankroll (+ve/-ve).
The bulk insert is applied atomically, but each inserted row still has to respect its constraints. One big reason you'd want to accumulate rolls in-memory and then commit them to the DB in bulk is if each roll needs to be applied sequentially to the DB and you don't want sequential roll insertion to be the bottleneck. For example, imagine if each roll needs to calculate the total house bankroll to adjust the edge of the roll. The bankroll changes each roll. If each roll has to hit the DB server, then you're going to be dealing with a lot of insert contention. Instead, let's say you only make one DB insertion at the turn of each second. As rolls come in, you buffer the results in memory (assured that the DB cannot change during this time) and then commit all the rolls at once. Here's an idea: imagine if you write a function `roll(prevDB, params)` that returns `newDB` where prevDB and newDB are just associative datastructures that represent the state of the DB in memory. That means you can `reduce(roll, prevDB, [params, ...])` where `[params, ...]` is a sequence of user roll parameters coming down, say, a websocket. At the turn of each second, you stop the reduction, take the latest newDB value (the result of all the buffered rolls), and commit it to the DB. The post-commit value of the DB is now your `prevDB` that you feed back into the reduction and resume processing rolls. I was thinking about what u said. Instead of storing in the memory pool, how about storing it in a text file and insert the data of that text file after a certain time interval, say one minute and remove the old data from there. Real time display can be done from the text file itself.
|
|
|
|
NLNico
Legendary
Offline
Activity: 1876
Merit: 1295
DiceSites.com owner
|
|
September 26, 2014, 03:42:44 AM Last edit: September 26, 2014, 04:46:15 AM by NLNico |
|
I like the idea of knowing this, so let's make an overview (grouped by backend language, not really sorted) Site | Server | Backend | Socket lib | DB/Storage | Frontend | Just-Dice.com | | Node.js | socket.io | redis+MySQL | | PrimeDice.com | Cowboy | Node.js | socket.io | PostgreSQL | EmberJS | DiceBitco.in | nginx | Node.js+Express | Primus | | AngularJS | Dicenow.com | nginx | Node.js+Express | socket.io | | AngularJS | Satoshibet.com | nginx | Node.js | socket.io | | | MoneyPot.com | Cowboy | Node.js | socket.io | PostgreSQL | | PRCDice.eu | MS-IIS | .NET | SignalR | | | Win88.me | MS-IIS | .NET | ServiceStack | | AngularJS | Peerbet.org | MS-IIS | .NET | --- | | | Dice.ninja | cyclone | Python | sockjs-cyclone | MySQL | | luckyb.it | | Python+Flask | --- | | | Rollin.io | Apache | PHP+laravel | socket.io | | | BitDice.me | nginx | RoR+RabbitMQ | | Redis+MySQL | |
More / corrections? Let us know
|
|
|
|
a1choi
|
|
September 26, 2014, 07:51:16 AM |
|
thanks for sorting this out to a table format! way easier on the eyes
|
|
|
|
BitCoinDream
Legendary
Offline
Activity: 2394
Merit: 1216
The revolution will be digital
|
|
September 26, 2014, 01:42:39 PM |
|
I like the idea of knowing this, so let's make an overview (grouped by backend language, not really sorted) Site | Server | Backend | Socket lib | DB/Storage | Frontend | Just-Dice.com | | Node.js | socket.io | redis+MySQL | | PrimeDice.com | Cowboy | Node.js | socket.io | PostgreSQL | EmberJS | DiceBitco.in | nginx | Node.js+Express | Primus | | AngularJS | Dicenow.com | nginx | Node.js+Express | socket.io | | AngularJS | Satoshibet.com | nginx | Node.js | socket.io | | | MoneyPot.com | Cowboy | Node.js | socket.io | PostgreSQL | | PRCDice.eu | MS-IIS | .NET | SignalR | | | Win88.me | MS-IIS | .NET | ServiceStack | | AngularJS | Peerbet.org | MS-IIS | .NET | --- | | | Dice.ninja | cyclone | Python | sockjs-cyclone | MySQL | | luckyb.it | | Python+Flask | --- | | | Rollin.io | Apache | PHP+laravel | socket.io | | | BitDice.me | nginx | RoR+RabbitMQ | | Redis+MySQL | |
More / corrections? Let us know That's a wonderful job done. Does anyone know what PocketDice.io is using ? Its also interesting to see that almost none of the players are using PHP.
|
|
|
|
NLNico
Legendary
Offline
Activity: 1876
Merit: 1295
DiceSites.com owner
|
|
September 26, 2014, 02:34:47 PM Last edit: September 26, 2014, 02:46:13 PM by NLNico |
|
PocketDice.io = nginx, PHP, socket.io, AngularJS About that lack of PHP sites: IMO every developer has to look per project what language and frameworks to use. Node.js is single threaded by design and is perfect for realtime communication between the browser and server. It just makes sense to use it for chatrooms, games, etc. aka dice/gambling sites It doesn't mean that PHP is necessarily bad, it's just bad for this type of website. Better yet: the 2 websites with PHP still use socket.io (node.js) for the socket. On the other hand, suggesting a MEAN (MongoDB, Express, AngularJS, and Node.js) stack for a normal informative company CMS wouldn't make much sense either (IMO.) I would prefer PHP and/or an open-source CMS for that specific goal.
|
|
|
|
BitCoinDream
Legendary
Offline
Activity: 2394
Merit: 1216
The revolution will be digital
|
|
September 26, 2014, 03:09:05 PM |
|
PocketDice.io = nginx, PHP, socket.io, AngularJS About that lack of PHP sites: IMO every developer has to look per project what language and frameworks to use. Node.js is single threaded by design and is perfect for realtime communication between the browser and server. It just makes sense to use it for chatrooms, games, etc. aka dice/gambling sites It doesn't mean that PHP is necessarily bad, it's just bad for this type of website. Better yet: the 2 websites with PHP still use socket.io (node.js) for the socket. On the other hand, suggesting a MEAN (MongoDB, Express, AngularJS, and Node.js) stack for a normal informative company CMS wouldn't make much sense either (IMO.) I would prefer PHP and/or an open-source CMS for that specific goal. How do u get to know what is being used in the backend ? Moreover, as I understand, the use of socket.io is to auto-update the latest data in the front end. So, what would be the drawback if we store the data temporarily in a flat file and auto-refresh the flat file using JS ?
|
|
|
|
NLNico
Legendary
Offline
Activity: 1876
Merit: 1295
DiceSites.com owner
|
|
September 26, 2014, 03:44:05 PM |
|
Well, for example pocketdice.io sends a PHPSESSID cookie, so it's safe to say they use PHP ( https://pocketdice.io/index.php works too ). Besides that, you can easily see the socket.io socket. A socket is an open connection between the client (browser) and server with bidirectional communication. If you make a bet, you send the info through the socket (and you get the result) and if others bet you get the bets from there. So it's all real-time, you only connect once. There are different libraries/servers for this, Socket.io is a popular one made in node.js. Perfect for a dice site. An alternative is indeed getting new data with AJAX requests. With that, the browser would make a connection/request every x seconds to see if there are new bets. Obviously for a dice site this would be pretty terrible and give big lag and other problems. However AJAX is useful for other purposes.
|
|
|
|
addi
|
|
September 26, 2014, 07:05:33 PM |
|
We use mySQL & mongo for db (satoshibet)
|
|
|
|
newIndia
Legendary
Offline
Activity: 2226
Merit: 1052
|
|
September 26, 2014, 08:51:14 PM |
|
Well, for example pocketdice.io sends a PHPSESSID cookie, so it's safe to say they use PHP ( https://pocketdice.io/index.php works too ). Besides that, you can easily see the socket.io socket. A socket is an open connection between the client (browser) and server with bidirectional communication. If you make a bet, you send the info through the socket (and you get the result) and if others bet you get the bets from there. So it's all real-time, you only connect once. There are different libraries/servers for this, Socket.io is a popular one made in node.js. Perfect for a dice site. An alternative is indeed getting new data with AJAX requests. With that, the browser would make a connection/request every x seconds to see if there are new bets. Obviously for a dice site this would be pretty terrible and give big lag and other problems. However AJAX is useful for other purposes. Is there any special server setup required to run Node.js & socket.io ? Can I try it on a PHP-MySQL shared hosting ?
|
|
|
|
NLNico
Legendary
Offline
Activity: 1876
Merit: 1295
DiceSites.com owner
|
|
September 26, 2014, 11:39:59 PM |
|
Yes, you need to run Node.js so you will need an own server (perhaps there are very few shared hosting packages that do support it.) However you can always try it locally (and/or in a VM)
|
|
|
|
grux
Member
Offline
Activity: 67
Merit: 10
|
|
September 27, 2014, 02:37:56 AM |
|
We use mySQL & mongo for db (satoshibet)
That's an odd combo, are you using mongo to cache numbers? (if you don't mind me asking)
|
|
|
|
newIndia
Legendary
Offline
Activity: 2226
Merit: 1052
|
|
September 27, 2014, 09:47:05 AM |
|
We use mySQL & mongo for db (satoshibet)
Is not MongoDB a NoSQL database ? Can it go hand in hand with a RDBMS like MySQL ?
|
|
|
|
m19
|
|
September 27, 2014, 11:25:17 AM |
|
We use mySQL & mongo for db (satoshibet)
Is not MongoDB a NoSQL database ? Can it go hand in hand with a RDBMS like MySQL ? It could be they use MongoDB for session storage. Although I personally prefer Redis for that. Using a good ORM you can query both MySQL and MongoDB with the same syntax. For example Waterline ORM can do this.
|
|
|
|
newIndia
Legendary
Offline
Activity: 2226
Merit: 1052
|
|
September 28, 2014, 11:09:03 AM |
|
Yes, you need to run Node.js so you will need an own server (perhaps there are very few shared hosting packages that do support it.) However you can always try it locally (and/or in a VM) Thank U for the clarification... Does anyone know how many concurrent connection a gambling site experience at most ? Here I'm talking about the Web Server connection... NOT DB connection.
|
|
|
|
Dabs
Legendary
Offline
Activity: 3416
Merit: 1912
The Concierge of Crypto
|
|
September 28, 2014, 02:56:03 PM |
|
Hmmm..... you know, I recently heard about this guy in my country (Philippines) that runs an online casino. I don't know which one, but he has an office somewhere in Makati and he's got a staff of 100 people (probably customer support.)
I'm pretty sure it's not a bitcoin casino.
I'll try to get in touch, but it would seem I would have a difficult time getting an appointment; unless I point out to him that "Hey, if you accept bitcoin deposits, you save 3% from all those real-bank transaction fees."
Do you guys have a suggestion what I should use if I wanted to run my own dice site? Are all these sites using VPS or Amazon or something? Seems like Node.js is a good start.
I'd almost have to be some Massively Multiplayer Dice Playing Game, ... World of Dicecraft or something - I wouldn't use that particular name... (there's Dragon's Tale, too.)
And I'm left wondering if I just use IRC for the chat part, but then I'd have to worry about ops and channel maintenance.
|
|
|
|
newIndia
Legendary
Offline
Activity: 2226
Merit: 1052
|
|
September 28, 2014, 07:00:37 PM |
|
Hmmm..... you know, I recently heard about this guy in my country (Philippines) that runs an online casino. I don't know which one, but he has an office somewhere in Makati and he's got a staff of 100 people (probably customer support.)
I'm pretty sure it's not a bitcoin casino.
I'll try to get in touch, but it would seem I would have a difficult time getting an appointment; unless I point out to him that "Hey, if you accept bitcoin deposits, you save 3% from all those real-bank transaction fees."
Do you guys have a suggestion what I should use if I wanted to run my own dice site? Are all these sites using VPS or Amazon or something? Seems like Node.js is a good start.
I'd almost have to be some Massively Multiplayer Dice Playing Game, ... World of Dicecraft or something - I wouldn't use that particular name... (there's Dragon's Tale, too.)
And I'm left wondering if I just use IRC for the chat part, but then I'd have to worry about ops and channel maintenance.
Please ask him how is he currently accepting payment from customers ? AFAIK PayPal does not allow to do gambling payment. Moreover, does he have a license ?
|
|
|
|
Dabs
Legendary
Offline
Activity: 3416
Merit: 1912
The Concierge of Crypto
|
|
September 29, 2014, 12:52:26 AM |
|
Please ask him how is he currently accepting payment from customers ? AFAIK PayPal does not allow to do gambling payment. Moreover, does he have a license ?
I'll ask. I don't know anything yet and can't make any assumptions, I was just guessing based on the story. (Also, supposedly a friend of a friend, so that's going to be a bit more difficult to track down.)
|
|
|
|
Dabs
Legendary
Offline
Activity: 3416
Merit: 1912
The Concierge of Crypto
|
|
September 29, 2014, 01:21:38 AM |
|
Speaking of which, almost everyone is using HMAC-SHA-512.
Since HMAC is not broken, why not use HMAC-SHA-1 (which is what Google Authenticator 2FA uses) for the dice rolls? Or if that's questionable, why not HMAC-SHA-256?
In fact, HMAC-MD5 would probably work fine. (MD5 is broken, but not HMAC.)
You'll have a few gamblers trying to figure out the secrets.
Also, I thought I might ask here since all these sites are here, how do you get an unbiased roll of a 6 sided dice based on binary input (such as the hash result). The only thing I can think of is using the discard method. If I don't discard, there is a bias. On one hex digit, that's .25, on two, that's 0.015625.
Some sites use 5 digits, then discard if too high, for their million sided dice. I could use, maybe 12 hex digits for a trillion sided dice without discarding, while the bias may exist, it's too small at the point. (Who the hell is going to do a trillion rolls on one set of seeds to find out ... well, there's me ...)
So, as an alternative, I thought of inventing a new game using 8 sided dice instead. Much easier to map out to a hex digit, no bias. (Oh, I know I could just use a thousand sided dice, or a million sided dice like any of the top 5 dice sites, but I'm trying to do something different.)
|
|
|
|
NLNico
Legendary
Offline
Activity: 1876
Merit: 1295
DiceSites.com owner
|
|
September 29, 2014, 01:49:02 AM |
|
What is the problem with HMAC-SHA512? If there is no problem with it, why use a weaker alternative?
|
|
|
|
Dabs
Legendary
Offline
Activity: 3416
Merit: 1912
The Concierge of Crypto
|
|
September 29, 2014, 02:24:54 AM |
|
What is the problem with HMAC-SHA512? If there is no problem with it, why use a weaker alternative?
Speed? (No seriously.) You know what, maybe it was just a dumb question, who is going to notice the speed difference even when you have a few thousand players online at the same time on one server. But I had to ask it anyway. I did some quick research, and I think I won't go with MD5 or SHA1 at least. Someone else made this speed test on the hash functions: MD5 10.275190830230713, 10.155328989028931, 10.250311136245728 SHA1 11.985718965530396, 11.976419925689697, 11.86873197555542 SHA256 16.662450075149536, 21.551337003707886, 17.016510963439941 SHA512 18.339390993118286, 18.11187481880188, 18.085782051086426 atodorov.org/blog/2013/02/05/performance-test-md5-sha1-sha256-sha512/ And there's an older one here: http://www.cryptopp.com/benchmarks.htmlThe HMAC, if I understand it correctly, does two hashing calculations. So if MD5 = 20, and SHA512 = 36 ... (Okay okay, maybe it's a really dumb question.)
|
|
|
|
|