6 ms·
HN Plays 2048
- granttimmerman 13y agoMan... scalability sucks.
- Oculus 13y agoTook a look at your code and noticed you're using Socket.io. Don't use Socket.io for anything over double digit concurrent users. It's well known to be horrible at scaling. If you want something that's better at scaling I'd suggest SockJS[1]. 1 - https://github.com/sockjs/sockjs-node https://github.com/sockjs/sockjs-node
- granttimmerman 13y agoI'll look into it. Thanks
- alecsmart1 13y agoYour app's down :(
- deleted 13y ago[deleted]
- bib971 13y agoAnything to backup your claim about Socket.io?
- DigitalSea 13y agoThis is a rather inaccurate statement to make. I've used Socket.io with double digit concurrent users before and Socket.io handled things fine.
- derefr 13y agoYou're not disagreeing with the parent. They said more than double-digit.
- ahdinosaur 13y agoi'd suggest https://github.com/primus/primus https://github.com/primus/primus. it's an abstraction layer for real-time so no lock-in to a single socket implementation. it's simple and extensible by plugins.
- gargarplex 13y agoSeconded. I ran a very popular website that used Socket.IO. It broke down whenever we had 200+ concurrent users. Sockets would randomly close.
- babuskov 13y agoThe "over double digit" claim is simply not true. I'm running three multiplayer games for about two years now, and it starts to have problems once if goes over 3500 concurrent connections. It could be that I just hit the right combination of node+socketio versions, though, as I had problems with newer ones. My setup is: node.js 0.6 socket.io 0.9.6 This version of socket.io has a nasty bug in jsonp protocol handling which I patched manually by merging some change from a newer version, but it does work fine. To make it scale, I run multiple node processes. In the last 300+ days each of those has between 1000 and 2000 concurrent connections all the time and it works fine. Except that there is some memory leak (I'm not sure if it's related to socket.io or some other lib), so I restart each server once a week (it's done automatically each Sunday at 2am). I had my eye on SockJS since 2012, and it looks like newer versions are really good, but I'd need upgrade to newer nodejs and this is simply not possible for the existing projects as many used modules are not available. However, if you're starting a new project, it's worth testing and see which performs better.
- feronull 13y agoWe also do had a memory leak because of socket.io 0.9.6 take a look at this discussion https://github.com/LearnBoost/socket.io/issues/1303#issuecomment-33107520 https://github.com/LearnBoost/socket.io/issues/1303#issuecom...
- babuskov 13y agoInteresting, but I'm not using Redis nor MemoryStore. I gave each machine behind HAProxy a different hostname (mapped to the same IP address), and I route the clients in roundrobin fashion to each of those before they open the page with socket.io javascript. It works like this: - client opens a page on HAProxy load-balancer picked server - the actual node server that receives the request, redirects the browser to its custom hostname using the same URI - client opens the same page on the particular server and socket.io connects to that subdomain This ensures that all future requests (if socket.io connection is broken) will go to the same server without Redis, MemoryStore, cookies or whatever. Drawbacks: - one additional HTTP redirect when page that contains socket.io is loaded (luckly, in games there aren't many of those) - if you want to retire some sub-domain hostname, you have to be careful to allow existing clients to re-connect somewhere else. Not really a problem for my setup, but YMMV.
- ttty 13y ago"Under the hood SockJS tries to use native WebSockets first. If that fails it can use a variety of browser-specific transport protocols and presents them through WebSocket-like abstractions." - SockJS How this is helping? "Flash is absolutely not required for Socket.IO to function. If Flash is available, it'll be leveraged, as it provides almost the same capabilities as WebSocket. If it's not, the next best transport will be chosen." - Socket.io
- Oculus 13y agoMy understanding is the issue is not in the protocols, but in the implementation of the libraries themselves.
- coreymgilmore 13y agoIt would be nice to know your own user #.
- granttimmerman 13y agoGood idea! I'll make an issue for this on Github.
- granttimmerman 13y agoYour own user inputs are now bolded Commit: https://github.com/grant/hnplays2048/commit/308f68341b2c54bf672b40c0c6de300bbd72af10 https://github.com/grant/hnplays2048/commit/308f68341b2c54bf...
- colept 13y agoThis game is no more playable than it was when it was posted hours ago. And here's why: setInterval(function() { window.manager.inputManager.emit("move", Math.floor(Math.random() * 3) + 1); }, 1000); Some rate limiting has been put in place, but it's not good enough. If there are 50 users online at once, they all shouldn't be able to spam a command every second. A better algorithm would be: seconds_between_commands = 60 - (60 / number_of_players); With a clock letting you know when you can make your next move. Otherwise, it's just way too easy to spam.
- granttimmerman 13y agoGood idea. Working on it.
- bhaumik 13y agoIs this HN's version of twitch plays Pokemon? http://www.twitch.tv/twitchplayspokemon http://www.twitch.tv/twitchplayspokemon
- saraid216 13y agoYes. Explicitly. https://news.ycombinator.com/item?id=7431436 https://news.ycombinator.com/item?id=7431436
- joyeuse6701 13y agothe chaos.
- begriffs 13y agoIt's currently unplayable. Instead imagine if it would make one move every half a minute. During the time between moves anyone could vote on the next move. Then the winning move would be played. It would be a slow game, but would be the aggregate HN wisdom.
- sillysaurus3 13y agoThis is awesome. It's anarchic and chaotic and amazing. I can't wait until it falls off the frontpage and drops to 5 users. EDIT: We killed it. Nooo.
- granttimmerman 13y agoShould be online now.
- alanfalcon 13y agoAnd we could name that mode democracy, but we could have a meta game where people vote on anarchy (current system) or democracy, as you describe. And there should be fan art.
- Cub3 13y agoWe really need a democracy mode for this
- fblp 13y agoit has been added and is awesome
- comrh 13y agoThis seems to show what I thought when I originally saw the game, that random spamming would get you pretty far.
- grej 13y agoKind of fun, but I agree with some of the other comments that it would be interesting to see what would happen if the app made a move every 15-20 seconds based on the vote tally in that time window.
- cube_yellow 13y agoRight. It needs a Democracy mode. maybe even a Democracy/Anarchy slider controlled by Q and E.
- MCompeau 13y agoI feel like this undermines the true spirit of HN Plays 2048
- dbieber 13y agoAsk and you shall receive http://hnplays2048-democracy.herokuapp.com/ http://hnplays2048-democracy.herokuapp.com/ Edit: Now integrated into the OP's app
- granttimmerman 13y agoThanks for the feature, dbieber!
- zeyus 13y agoUsers should only be able to vote once (maybe be allowed to change it, but right now someone can overrule the consensus by hitting an arrow key as many times as they can) Nice work though!
- granttimmerman 13y agoHey guys, it's the creator here. I never thought this little project would get this big! If someone wants to help me scale this, or add things like chat, please do! Just send a PR on Github! https://github.com/grant/hnplays2048 https://github.com/grant/hnplays2048
- addisonj 13y agoI literally was going to do this this coming weekend, same name even! I was going to take a much different approach however - I was going to use rabbitmq speaking STOMP over a websocket [0] with two queues, one for client moves, which the server would consume and write to the moves queue, which each client would consume. This would allow the server to do more fancy rate limiting / throttling as not to just lead to a message storm. This, along with storing the game state in a db, allows for scaling out app servers. 0 - https://www.rabbitmq.com/blog/2012/05/14/introducing-rabbitmq-web-stomp/ https://www.rabbitmq.com/blog/2012/05/14/introducing-rabbitm...
- ankit84 13y agoA joKE?
- theandrewbailey 13y agoseems like it falls victim to popularity, and crashes often.
- deleted 13y ago[deleted]
- azinman2 13y agoI really don't like to hate on other people's work but seriously more 2048 forks? And now ones that aren't even remotely playable?
- theandrewbailey 13y agoMake 2048 forks, not war.
- ghiculescu 13y agoThis is probably a bit much, but I'd love to see someone whip up a multiplayer 2048 using something like Firebase. It would probably start many an argument.
- vinh0811 13y agoHere is my app for Android: https://play.google.com/store/apps/details?id=com.contrarykid.twos https://play.google.com/store/apps/details?id=com.contraryki...
- gk1 13y agoA-a-and it's down.
- joeblau 13y agoCan someone index all of these versions :)
- mkoryak 13y agoyou guys really suck at this game.
- dwd 13y agoI'd love to give people the benefit of the doubt and attribute it to spoilers who intentionally move it against the flow, but I have my doubts.
- Dobbs 13y agoThis needs a delay. That way you can follow the chaos instead of just staring at a moving screen.
- mcescalante 13y agoAnother case of "HN crashes the heroku app"
- evidencepi 13y agoLOL
- dbieber 13y agoI added democracy mode... The pull request is here: https://github.com/grant/hnplays2048/pull/10 https://github.com/grant/hnplays2048/pull/10 You can play it here: http://hnplays2048-democracy.herokuapp.com/ http://hnplays2048-democracy.herokuapp.com/
- aturek 13y agoDemocracy mode is great! But a couple of players (and I) figured out that multiple key presses by a user are counted, so we have more of an oligarchy determined by whoever can spam keystrokes...
- richard_cubano 13y agoI like this one a bit better because it shows vote totals and has a visible countdown: http://voting-2048.herokuapp.com/ http://voting-2048.herokuapp.com/
- richard_cubano 13y agoPull Request if anyone wants to see the code. Sorry this is in 2 places. https://github.com/grant/hnplays2048/pull/13 https://github.com/grant/hnplays2048/pull/13
- PeterisP 13y agoDemocracy mode needs a chat to scream about the occasional horribly stupid moves voted (merge a mid-value pair that prevents a win because it blocks in a low value cell between the 256's)
- evidencepi 13y agoCrashed!!
- kregasaurusrex 13y agoStart9
- stefan_kendall3 13y agoAnarchy lasted minutes before the democracy babies came running in.
- munimkazia 13y agoUtter chaos going on in the game over there. But it's a fun experiment.
- tomaskazemekas 13y agoIt is a good demonstration that in cases like this user democracy is a loosing strategy.
- Smirnoff 13y agoDamn, this version seems so unplayable-- so much chaos. When I play on my own, I already do so many random moves until I reach 512. After that every move that I make is evaluated. I have no problems reaching 2048 (or 29,000 points) within 10-15 minutes. Here, I just get frustrated with the slowness of the moves (not to mention the strategy of the "democratic group" is way off)
- yaddayadda 13y agohttp://xkcd.com/1344/ http://xkcd.com/1344/
- maaarghk 13y agoholy hell this makes me hate you all! =P
- martinthenext 13y agoIt's pretty interesting how the strategy derived by averaging over multiple intelligent users can be that sub-optimal.
- lerg 13y agoI've made a version of 2048 on Hexagonal Board - check it out https://play.google.com/store/apps/details?id=com.spiralcodestudio.hexled https://play.google.com/store/apps/details?id=com.spiralcode...
- spajus 13y agoThis makes a perfect illustration why startups are shit. Instead of working on something useful, people either produce crappy javascript games, or play them. Now massively downvote this comment, write 100 replies explaining why I'm wrong and how retarded I am for trying to say something like this, then go read something by Paul Graham and play more clones of 1024. And then write a long essay why your startup failed.