Facebook App - How to fix lag?

Status
Not open for further replies.

a!!!!1

Banned
Apr 20, 2008
508
7
0
I hired some people on Elance to help code my Facebook/Myspace app, it's been going pretty smoothly but they just sent me this message:

But we have a problem, some of the major aspects of the game are still unsettled, like the support of Multiplayer Gaming modes because smartfox doesn't support UDP which is required for this game as this game will invoke heavy and instant data exchange between the player PC's and server and under TCP protocols (which smartfox supports) the game will definitely Lag like anything.
The app is a flash game that features a multiplayer mode where 4 players can play with each other, and other people can also join ongoing games to spectate.

Does anyone know what they're talking about because I didn't understand it at all?
 


Basically saying the application could communicate much faster over a UDP port, but "smartfox" (not sure what program that is), doesn't support UDP and as a result needs to go with a slower TCP connection. Least thats what they seem to be saying.

This might be a bit of a bore for you to read but...

TCP and UDP Ports Explained
TCP/UDP Ports Explained
Introduction

In this tutorial we will discuss the concept of Ports and how they work with IP addresses. If you have not read our article on IP addresses and need a brush up, you can find the article here. If you understand the concepts of IP addresses, then lets move on to TCP and UDP ports and how they work.

The devices and comptuers connected to the Internet use a protocol called TCP/IP to communicate with each other. When a computer in New York wants to send a piece of data to a computer in England, it must know the destination IP address that it woud like to send the information to. That information is sent most often via two methods, UDP and TCP.

The two Internet workhorses: UDP and TCP

UDP? TCP? I know you are getting confused, but I promise I will explain this in very basic terms so that you can understand this concept.

TCP stands for Transmission Control Protocol. Using this method, the computer sending the data connects directly to the computer it is sending the data it to, and stay connected for the duration of the transfer. With this method, the two computers can guarantee that the data has arrived safely and correctly, and then they disconnect the connection. This method of transferring data tends to be quicker and more reliable, but puts a higher load on the computer as it has to monitor the connection and the data going across it. A real life comparison to this method would be to pick up the phone and call a friend. You have a conversation and when it is over, you both hang up, releasing the connection.

UDP stands for User Datagram Protocol. Using this method, the computer sending the data packages the information into a nice little package and releases it into the network with the hopes that it will get to the right place. What this means is that UDP does not connect directly to the receiving computer like TCP does, but rather sends the data out and relies on the devices in between the sending computer and the receiving computer to get the data where it is supposed to go properly. This method of transmission does not provide any guarantee that the data you send will ever reach its destination. On the other hand, this method of transmission has a very low overhead and is therefore very popular to use for services that are not that important to work on the first try. A comparison you can use for this method is the plain old US Postal Service. You place your mail in the mailbox and hope the Postal Service will get it to the proper location. Most of the time they do, but sometimes it gets lost along the way.

Now that you understand what TCP and UDP are, we can start discussing TCP and UDP ports in detail. Lets move on to the next section where we can describe the concept of ports better.

TCP and UDP Ports

As you know every computer or device on the Internet must have a unique number assigned to it called the IP address. This IP address is used to recognize your particular computer out of the millions of other computers connected to the Internet. When information is sent over the Internet to your computer how does your computer accept that information? It accepts that information by using TCP or UDP ports.

An easy way to understand ports is to imagine your IP address is a cable box and the ports are the different channels on that cable box. The cable company knows how to send cable to your cable box based upon a unique serial number associated with that box (IP Address), and then you receive the individual shows on different channels (Ports).

Ports work the same way. You have an IP address, and then many ports on that IP address. When I say many, I mean many. You can have a total of 65,535 TCP Ports and another 65,535 UDP ports. When a program on your computer sends or receives data over the Internet it sends that data to an ip address and a specific port on the remote computer, and receives the data on a usually random port on its own computer. If it uses the TCP protocol to send and receive the data then it will connect and bind itself to a TCP port. If it uses the UDP protocol to send and receive data, it will use a UDP port. Figure 1, below, is a represenation of an IP address split into its many TCP and UDP ports. Note that once an application binds itself to a particular port, that port can not be used by any other application. It is first come, first served.

In a nutshell TCP is more processor intensive and guided for the app to use, then UDP.
 
UDP datagrams are not guaranteed to make it from peer-to-peer because they can timeout after a certain number of hops

TCP is guaranteed to make it (in the proper order) so if one datagram is late, it will hold up all the rest, thus slowing it down
 
So basically they're saying TCP won't work for this particular app because it would be too slow and cause it to lag, so they have to use UDP. But they're using something called "Smartfox" that doesn't support UDP. So wouldn't the only option be to not use Smartfox?
 
SmartFox is a server written in java so it can be deployed anywhere. It's main focus is on flash applications. If SmartFox can't handle it you'll have to use some other type of server.
 
From how it's looking its purely on Flash's side too, Flash doesn't support UDP - yet.
 
SmartFox is a server written in java so it can be deployed anywhere. It's main focus is on flash applications. If SmartFox can't handle it you'll have to use some other type of server.

Why don't they just do that then? SmartFox isn't the only type of server is it?
 
Why don't they just do that then? SmartFox isn't the only type of server is it?

Like I said above, the problem isn't with the server it's the fact that Flash doesn't support UDP openly so you can't program Flash to use it, so there's no reason for the server to have it. Your going to have to deal with the TCP issue or rip it all down and do it up in Java or something.
 
Alright. Is TCP guaranteed to lag? The issue is that my app is a multiplayer game and I wanted 4 players to be able to join a single game and play in the same playing field (so they can interact with each other), and they're saying this is gonna be impossible to do without it lagging.
 
Alright. Is TCP guaranteed to lag? The issue is that my app is a multiplayer game and I wanted 4 players to be able to join a single game and play in the same playing field (so they can interact with each other), and they're saying this is gonna be impossible to do without it lagging.

4 players, probably will be lag. Flash wasn't meant to make multi-player games. Your best hope would to try and make the game more turn based and then your issue would be fine.
 
What about each player playing his own game but having little windows to spectate his opponents' games? I know there was a Tetris game that did that.

Also you suggested totally redoing it in Java, would that be able to handle what I'm trying to do?
 
Could do something like you mentioned first, the view window may lag like mad I guess.

Your best bet is to so it up in Java, especially for speed.
 
So he's been "doing some research" into which method he thinks would be better and I got this message this morning:

Just want to let you know that we did a research on all the possibilities available concerning the Flash Action Scripting Platform. The first one to go with is of course the Flash Media Interactive server itself as for now its the only platform that supports UDP with Flash. Here are some extracted details concerning FMIS implementation. Now there are two ways to get along with it, one way is to purchase the Flash Media Interactive server ( that costs US$ 4,500 ) and have it installed on any linux server (and you can check the requirements through this url Adobe - Flash Media Interactive Server 3.5: System requirements and languages ).

The second option is to obtain a dedicated Flash Media hosting service, through the given url you can check the some of the reliable Hosting Servers as recommended by Adobe itself Adobe - Flash Media Server: Flash Video Streaming Service .

Despite of this let me mention it again that the RTMFP the UDP protocol is still limited and going through an evolution as they mentioned it their official release documentation of Flash 10 (Release Notes RTMFP FAQS).

And apart from Flash Media Interactive Server, none of the alternatives support UDP with Flash. (i.e; Smartfox, Red5 & ElectroServer)

I'm not looking to spend another $4500 so that rules out the first possibility. I could go with the second option, the "flash media hosting service (recommended by Adobe)" but I wanted to get your opinions first as to whether that would be a good idea, costs, etc.

Or I could just tell him to just switch to Java. I think the reason he doesn't want to is they've already done all the graphics and started the coding in Flash and it would delay it, but if it's the best option, I don't mind a delay. Any thoughts would be appreciated.
 
As far as I see it UDP is still a long ways off. I'd say go with Java if it'll cost you less than 4500. It's there cock up IMHO that they thought they could do it in the first place.

So he's been "doing some research" into which method he thinks would be better and I got this message this morning:



I'm not looking to spend another $4500 so that rules out the first possibility. I could go with the second option, the "flash media hosting service (recommended by Adobe)" but I wanted to get your opinions first as to whether that would be a good idea, costs, etc.

Or I could just tell him to just switch to Java. I think the reason he doesn't want to is they've already done all the graphics and started the coding in Flash and it would delay it, but if it's the best option, I don't mind a delay. Any thoughts would be appreciated.
 
Status
Not open for further replies.