Solution to LAG, 500's and timeouts

Report bugs, registration issues, or just suggest some new features in this thread! Guaranteed to have at least 10% more dev attention than other threads!

Solution to LAG, 500's and timeouts

Postby fermixx on Wed Feb 08, 2012 6:22 pm

Hello world.
My name is Fermin and i'm a long time FC player (+2 years, although i don't show up here frequently) and a software developer.

Recently I've been really pissed off with the super poor performance the game has. I don't mind waiting a bit, but sometimes the requests just die and there's no way to recover (you loose designs, contraptions, levels, etc).


What I'm looking for is a solution to this (even if i need to develop it).
I already have some ideas in my mind, but im looking for some feedback (because development time is precious).
The idea is, basically
[*]For non techie guys:
Point FC to another optimized server for saving and retrieving levels and designs.

[*]For techie guys:
Set up a proxy that will filter the requests and point them to another server, that will return the same response as the original FC one, but much faster.


All the other requests still point to the original FC server (like forums for example).


PROS:
Super speed!
Everything gets saved
You can play offline (although with reduced functionality)

CONS:
You need to run the program that "points" FC to another server (just double click a windows app, no big deal)



What do you think about it?
Are you interested?
Should i spend time coding this?

Thanks for your feedback

(Any ideas, techie or not, are welcomed!)
Last edited by fermixx on Fri Feb 10, 2012 6:29 pm, edited 1 time in total.
fermixx
 
Posts: 21
Joined: Fri Sep 05, 2008 9:25 pm

Re: Solution to LAG, 500's and timeouts

Postby Jyo on Thu Feb 09, 2012 12:23 am

hey mate

im a ee/comp sci major at uc berk
but i unfortunately dont no anything about server management.

but in any case,
how exactly does the proxy work?
is the idea to try to create a server that will process requests faster than the FC server currently does?
User avatar
Jyo
 
Posts: 726
Joined: Fri Aug 29, 2008 11:25 pm
Location: Berkeley, CA

Re: Solution to LAG, 500's and timeouts

Postby lord_hamybal on Thu Feb 09, 2012 1:34 pm

yes Jyo..


fermixx even if you are going to make this, you can't link it without permission of these people who managed this site. and those people are not responding anymore(sorry for the english)
User avatar
lord_hamybal
 
Posts: 3360
Joined: Thu Oct 09, 2008 10:04 am

Re: Solution to LAG, 500's and timeouts

Postby fermixx on Thu Feb 09, 2012 6:20 pm

Jyo wrote:how exactly does the proxy work?
is the idea to try to create a server that will process requests faster than the FC server currently does?

Ok this is going to get techie:
The proxy intercepts the raw http requests that your browser does. These always go from the flash object to the FC server. Since i cannot break into the flash object, what i can do is to catch these http requests and point them wherever i want, even add custom data. This is no hacking at all since everything happens in your computer (at your own will).
I don't know what the actual backend this site has, but with fairly low-end hardware i managed to do well over 15k level fetchs by id PER SECOND, and pretty much the same amount of user designs + level per second ( and we all know this site doesnt have such a massive concurrency at all! ).

lord_hamybal wrote:fermixx even if you are going to make this, you can't link it without permission of these people who managed this site.

As I was explaining above, its you that run a proxy software IN YOUR LOCAL COMPUTER that points all the requests to server B instead of server A, which responds in the exact same way as A would do, so the flash game doesnt even notice :)
fermixx
 
Posts: 21
Joined: Fri Sep 05, 2008 9:25 pm

Re: Solution to LAG, 500's and timeouts

Postby Thik_Tip on Thu Feb 09, 2012 7:55 pm

Great idea fermixx.

Although I am only a simple music teacher, I think I understand what you are trying to do. Let me see if I've got it. When you click on the "Save" button to save your design the Proxy will intercept the request to save it to the FC Server and direct it to save to another/faster server. Now my question has to do with what can be done subsequently with the saved designs. Personally, I am slightly bothered with the idea of not having my designs saved to the FC Server at all. I think that just as Lord Hamybal stated
lord_hamybal wrote:even if you are going to make this, you can't link it without permission of these people who managed this site and those people are not responding anymore.

this may be a problem.

Here is my idea of a work-around... I don't know if it is possible, but can you do the following?

Start off by Intercepting the http request and save the design to "Server B". Now, while I continue to work on my design unimpeded by the FC Server (Server A), can there be a script that resends the http request back to the FC Server on a continuous loop until it eventually saves? That way you can get the best of both worlds; You can continue to work on your designs and every design will eventually be saved to the FC Server.

If that can be done, I would definitely be onboard with it.

Thik Vic
User avatar
Thik_Tip
 
Posts: 713
Joined: Wed Mar 11, 2009 7:52 pm
Location: Fresno, California

Re: Solution to LAG, 500's and timeouts

Postby jdccdj1 on Thu Feb 09, 2012 9:22 pm

jdccdj1: I have a question, say we get into the program, and through the security measures there and down the through the bubbles we can't move, and past the guarded firewalls, and into the database we can't open...
lord_hamybal: Without being seen by the FC techies.
fermixx: Oh yeah, sorry, I forgot to mention that.
jdccdj1: Yeah well, say we do all that... uh... we're just supposed to walk out of there with our designs intact, without getting stopped?
[pause as everyone turns to look at fermixx]
fermixx: Yeah.
jdccdj1: Oh...Okay....I'm in :)
User avatar
jdccdj1
 
Posts: 827
Joined: Sat Apr 16, 2011 7:59 am
Location: hangin' with Roland of Gilead

Re: Solution to LAG, 500's and timeouts

Postby Jyo on Thu Feb 09, 2012 11:53 pm

jdccdj1 wrote:jdccdj1: I have a question, say we get into the program, and through the security measures there and down the through the bubbles we can't move, and past the guarded firewalls, and into the database we can't open...
lord_hamybal: Without being seen by the FC techies.
fermixx: Oh yeah, sorry, I forgot to mention that.
jdccdj1: Yeah well, say we do all that... uh... we're just supposed to walk out of there with our designs intact, without getting stopped?
[pause as everyone turns to look at fermixx]
fermixx: Yeah.
jdccdj1: Oh...Okay....I'm in :)


wp sir.
User avatar
Jyo
 
Posts: 726
Joined: Fri Aug 29, 2008 11:25 pm
Location: Berkeley, CA

Re: Solution to LAG, 500's and timeouts

Postby fermixx on Fri Feb 10, 2012 11:29 am

Thik_Tip wrote:Start off by Intercepting the http request and save the design to "Server B". Now, while I continue to work on my design unimpeded by the FC Server (Server A), can there be a script that resends the http request back to the FC Server on a continuous loop until it eventually saves?

It is definitely possible to make a loop in the proxy and keep trying until you get a response back, and only then answer "OK" to the flash object.

There's a problem however if you want the fast server to answer something while the slow one is still processing: which level id should i give you back? Although i can generate a new id instantly, the slow FC server might not give me the same id i gave to you early. Why? because not everyone is going to be using my proxy and because not all requests are going to be processed in the same order at the FC server.

This imposes a problem for level saving, and your choice is:
A: Let me store your level immediately (which will have an id incompatible with FC)
B: Let me keep retrying until the server responds and give you that id (you may see the bubbles for a while, but it will never fail, and its actually stored on FC!)

I'd stick with option B.

For level retrieval there's no consistency problem at all. If server B has the level, it gives it back to you. If not, it first fetches it from FC server, stores it locally and gives it back to you (slow the first time, fast subsequently).
fermixx
 
Posts: 21
Joined: Fri Sep 05, 2008 9:25 pm

Re: Solution to LAG, 500's and timeouts

Postby lord_hamybal on Fri Feb 10, 2012 5:02 pm

i think if this all is just possible it would be great, just saying to you Fermixx.
you can get problems while doing so, permission is something thats really need to be aquired. otherwise you can get alot of trouble.

its not really problem just sayin...

how this Server B you talk about. is that "IN YOUR LOCAL COMPUTER" what you told me earlier?
because if it isn't my computer i actually still bothering.

because 1 from who is this server? 2 what happens if there is something to happen to this server? all our designs gone?

-edit

Still thank you for all you efford! you are doing this for all of us.

did you already start your project? i mean did you already test what you just told us?

Rémy
User avatar
lord_hamybal
 
Posts: 3360
Joined: Thu Oct 09, 2008 10:04 am

Re: Solution to LAG, 500's and timeouts

Postby fermixx on Fri Feb 10, 2012 6:34 pm

lord_hamybal wrote:how this Server B you talk about. is that "IN YOUR LOCAL COMPUTER" what you told me earlier?

What runs in your local computer is the proxy that redirects requests to a new server B. This server B keeps trying to communicate to FC (it has the ability to retry, while the flash game doesnt). This is for level and design saving, which needs to be really secure in the original infrastructure.

Later on when you ask for a level (not saving, just retrieving), the proxy looks at it's own cache (you may have visited the level before) and if the level is there returns immediately. If it's not there, it asks the server B (which is outside your computer, is a central one). If this server (which happens to run faster than FC's) has the level, it returns it. Otherwise it keeps trying against FC server until the level is fetched. It stores it so everyone can access it fast and passes it to your local proxy.
Now the level is: secured at FC server, cached in server B where everyone can retrieve it and cached in your local machine (for ultimate performance, and also for offline play).

lord_hamybal wrote:because 1 from who is this server? 2 what happens if there is something to happen to this server? all our designs gone?

1) i'll have to run it in my own house and if it doesnt perform well, go for a hosting.
2) if you don't install the proxy: you keep hitting FC server which is slow and if the communication fails you loose your design (have to refresh the page)
if you install the proxy but it's broken: you won't be able to do anything, but you can close the proxy and behave exactly as above.
if you install the proxy but server B is broken: your requests will take forever to complete, so close the proxy and behave as above.
if you install the proxy and server B is up: saving never fails (it may take a while though) and fetching levels is fast.

What is important to understand is that even if you talk to server B, this server will still talk to the official FC server. This is not a drop in replacement, this is a man-in-the-middle that forwards requests and makes sure everything gets to destination. But when you ask him something, he may return faster because it has copies of the levels.

lord_hamybal wrote:did you already start your project? i mean did you already test what you just told us?

I tested only level retrieval for now, and it works super fine! I didnt started the level saving resource yet, but it shouldnt be difficult.
What i didn't do yet is a good proxy client with a decent GUI (for now it's a primitive console app with local cache missing)


I'll be posting some explanatory pictures and diagrams if its still unclear.


Cheers
fermixx
 
Posts: 21
Joined: Fri Sep 05, 2008 9:25 pm

Re: Solution to LAG, 500's and timeouts

Postby compscure on Fri Feb 10, 2012 11:48 pm

sounds like it could be great, though a lot of work on your end. and would it take much $$ for bandwidth/server space?

I'm curious what the state of the official FC servers is. They've had to buy more space before. I assume next time it's full they won't bother.

Any chance designs could also be saved locally on our own machines (is that what you meant by playing offline)?

Honestly, I'm not sure there are enough active players any more to justify all the work you'd put in. But it would be pretty slick if you could pull it off.
User avatar
compscure
 
Posts: 2857
Joined: Wed Dec 17, 2008 9:24 pm

Re: Solution to LAG, 500's and timeouts

Postby fermixx on Sat Feb 11, 2012 6:14 am

compscure wrote:Any chance designs could also be saved locally on our own machines (is that what you meant by playing offline)?

Every level and or design that you fetch will be saved locally (but you need to see it at least once from the internet!).
Once that, you can play offline with no problems. However, if you want to save offline, that is complicated because i don't know which level id FC will give to you.
fermixx
 
Posts: 21
Joined: Fri Sep 05, 2008 9:25 pm

Re: Solution to LAG, 500's and timeouts

Postby lord_hamybal on Sat Feb 11, 2012 10:38 am

fermixx wrote:
compscure wrote:that is complicated because i don't know which level id FC will give to you.


if it isn't alot of work, could you test that also for us?

i really like this idea and i am sad i cannot help you with this, but if you got the time( and want to do it) then do as you please:D!
User avatar
lord_hamybal
 
Posts: 3360
Joined: Thu Oct 09, 2008 10:04 am

Re: Solution to LAG, 500's and timeouts

Postby fermixx on Sat Feb 11, 2012 1:13 pm

The only thing i can think of is giving you a super big level id (so we are all sure it doesnt collide with FC real ones).
The level is saved locally and thus nobody will be able to see it.

Later on, when you want to share the level, you untick a "play-offline" checkbox from a window app. Since you need a real level id, you save the level once again. This time it goes to FC server, so the id is valid to share.



By the way, an update on this:
I already have the local cache up and running (the second time you fetch a level its mega fast!). What im doing now is filling that cache with something so after you download the proxy for the first time there's something already in there, so you can hit the cache from time to time.
fermixx
 
Posts: 21
Joined: Fri Sep 05, 2008 9:25 pm

Re: Solution to LAG, 500's and timeouts

Postby Kalma on Sat Feb 11, 2012 1:40 pm

I'm a bit confused. What is the "server B" for if the user will save the level locally?

Are the people who made FCML tool and stuff still around? I assume those would need to be adjusted to work with all this. I've tried to make a level using FCML recently, but had to give up due to server problems. :(

Anyway, sounds good.
User avatar
Kalma
 
Posts: 267
Joined: Sat Jul 26, 2008 3:59 pm

Re: Solution to LAG, 500's and timeouts

Postby fermixx on Sat Feb 11, 2012 1:55 pm

Server B is just a second cache stage.

For now i'll stick with local, but in the future, the idea will be:

if you have it locally fetch it from there.
if you don't, try server B.
if server B doesn't have it, try FC, then save to server B (visible for all proxy users, not just you), then save to your local machine.

This three level tier is like:
1 - local but very fast (only files you've seen are here)
2 - centralized and somewhat fast (only files all proxy users have seen are here)
3 - centralized and really slow (all files are here since it's the official one).

You want to hit tier-1 as much as possible, and tier 3 only very few times. tier 2 is just a balance in between the two.

i'm not sure how FCML works, does it directly talk to FC server or what? The website http://fc.tetsunosuke.co.cc/webfcml/ seems to be down
fermixx
 
Posts: 21
Joined: Fri Sep 05, 2008 9:25 pm

Re: Solution to LAG, 500's and timeouts

Postby Pawel.Anikiel on Sat Feb 11, 2012 2:17 pm

User avatar
Pawel.Anikiel
 
Posts: 423
Joined: Mon Jul 06, 2009 1:47 pm
Location: Gdynia, Poland

Re: Solution to LAG, 500's and timeouts

Postby fermixx on Sun Feb 12, 2012 1:38 pm

Update:

Got local cache done (it works instantly!) and filled it with about 15k levels to start with (i'm fetching more and more).
Got level saving done. What it does is to copy the http request you do to save the game somewhere safe, and hits the server until it replies something. This is the output of the program so far:


Info : Starting application
Info : Intercepted Request saveLevel2.php?xml=%3CsaveLevel%3E%0A%20%20%3Cname%3Eproxy%20test
Info : Trying to save level proxy test2
Info : Timeout for saving proxy test2
Info : Trying to save level proxy test2
Info : Timeout for saving proxy test2
Info : Trying to save level proxy test2
Info : Timeout for saving proxy test2
Info : Trying to save level proxy test2
Info : Timeout for saving proxy test2
Info : Trying to save level proxy test2
Info : Got id 596988 back from the server.
Info : Request handled correctly, now returning to browser

At this point the flash object returns after like 3 minutes of trying, but you finally get the level id back!
It's saved at FC servers so you can immediately share it.
fermixx
 
Posts: 21
Joined: Fri Sep 05, 2008 9:25 pm

Re: Solution to LAG, 500's and timeouts

Postby Pawel.Anikiel on Mon Feb 13, 2012 8:48 am

wow goood job dude! when it be finished?
User avatar
Pawel.Anikiel
 
Posts: 423
Joined: Mon Jul 06, 2009 1:47 pm
Location: Gdynia, Poland

Re: Solution to LAG, 500's and timeouts

Postby Thik_Tip on Wed Feb 15, 2012 10:34 am

Sweet!
User avatar
Thik_Tip
 
Posts: 713
Joined: Wed Mar 11, 2009 7:52 pm
Location: Fresno, California

Next

Return to Feedback and Problems



Who is online

Users browsing this forum: No registered users

cron