Espanol  |  English      

Archive

Archive for the ‘Uncategorized’ Category

Dealing with Facebook Platform latency issues

December 11th, 2009

A few days ago we started getting a “The URL … did not respond.” error in some apps that we were developing. We thought it could be caused by a Server Issue and we didn’t pay too much attention, but yesterday it started happening all the time, and there was no way to find a “pattern” of why was this being caused.

So we spent a couple of hours with Altodot’s hosting partner Atha Kouroussis ( Co-Founder at Vurbia Technologies) analyzing what was really happening, if it was a server problem, buggy code, or Facebook issue, and finally we found a way to fix this eternal errors thrown by Facebook.

One of the things we found is that some of the apps we made using IFRAME to run inside facebook were running slowly, but Ok anyways. So we started focusing on why would a FBML application fail when an IFRAME app doesn’t fail.

To confirm the post made by “Inside Facebook Blog” announcing Facebook’s API latency issues, when we started debugging the application we saw that the execution of the FQL queries was taking different response times, between 0.5 and three seconds generally, but suddenly appeared requests taking more than ten or even twenty seconds to run (including some other requests throwing zero records when they were supposed to retrieve existing records). The interesting thing was that it had nothing to do with the query itself, or the amount of records it was requesting…

That only explained why it was taking so much time to run the IFRAME apps, but why FBML applications were failing like that?… We took a deep look at the time it was taking to run all the FQL queries and we found that if the whole php execution was taking less than 12 seconds the FBML application worked fine, but if the response times of each FQL query (plus the time spent on the execution of the script) was over 12 seconds it failed.

The interesting thing here was that even when facebook throws the “URL did not respond” error, the execution of the script did not throw any exception and the logs on the web server showed a perfect delivery, instead of stopping the request it always finished it’s execution! no matter how much time it was taking to Facebook’s API to answer those requests.

We have the diagnosis so far, and it’s basically that facebook response latency is taking too much time, specially more that 12 seconds that it’s the time Facebook is going to wait for the output of your script before it starts parsing your HMTL + FBML tags on it.

Even when it clearly wasn’t our fault, that’s not an explanation that would make our clients feel happy or safe (Specially when we’re a company specialized on Social Apps), so we started brainstorming a few hours to get some kind of workaround.

We realized that we needed to do a redirection to the same page if the execution of the script takes more than 10 seconds to run, but since our app was built on PHP, we couldn’t check It the time elapsed after each query was less than 12 seconds, because only one query could take even 20 seconds and Facebook would throw the error before we have a chance to redirect the page.

The list of the possible solutions (after trying everything we found on Facebook Dev Forums) was too stretch, there were only three ideas:

  1. Pray for Facebook to take care of the latency issue (or extend,the output timeout),
  2. Change all the code to make the application run inside an IFRAME replacing all the FBML tags & FBJS scripts (obviously this was the latest thing we would do)
  3. Paralleling the calls to FQL servers.

Finally, the way that I solved the issue was simulating php threading by making calls through CURL to a processor file that takes care of making the FQL call to facebook, and while all the queries are being requested by multiple calls on curl on the main script we’re just looping and asking if those requests finished before 10 seconds. If that’s the case, we just let our script finish it’s execution, but if Facebook slowed at least one of the several FQL requests more than 10 seconds we just make a redirection to the same page passing all the parameters along with the redirect again. That way (and because Facebook usually didn’t  fail two times consecutive) it only takes 5 to15 seconds for the user to get the application content (not the 35 that could be on an IFRAME app if facebook takes 20 seconds to respond a query).

That said, let me share with you a working PHP sample script (commented) similar to what we’ve used to avoid facebook latency that you can download from here. Feel free to post any questions or comments about it.

Best,

Matias Paterlini

paterlinimatias Development, Facebook, Social Network, Uncategorized , , ,

Meet Isabella, my second daugther.

November 22nd, 2008

Hello my friends,

I wanted to share with you that my second daughter Isabella was born yesterday.

We’re so happy and so proud, she’s beautiful and we feel so blessed.

You can see some photos at:

http://www.facebook.com/album.php?aid=42050&l=fd6ab&id=587412625

Cheers!!

Matias Paterlini

paterlinimatias Uncategorized , ,

Finally, Google Maps In Argentina!!

November 14th, 2008

Desde el lunes, los usuarios locales podrán utilizar Maps para ver rutas y calles de la Argentina. En una próxima etapa, estarán disponibles funciones más avanzadas: búsqueda de direcciones, cómo llegar de un punto a otro, comercios, tráfico y transporte público. Se viene Street View.

Google hizo una excepción en su política sobre anuncios de nuevos productos. Pero la situación lo ameritaba: la Argentina era un espacio en blanco dentro de Google Maps, rodeada por cientos de rutas e información sobre la mayoría de los países vecinos.

Y fue así que decidieron comunicar que a partir del lunes, “en algún momento del día”, la Argentina dejará de ser un espacio en blanco. Los mapas de Google tendrán información sobre las rutas y calles del país.

“La información cubrirá los espacios en donde vive el 80% de la población”, mencionó Marcelo Quintella, product manager de Maps para América Latina. Es decir, las principales ciudades de la Argentina dispondrán desde el lunes de una información completa. “Ningún país está cubierto en un 100%”, se atajó.

Quintella viajó especialmente para el anuncio desde Belho Horizonte, Brasil, donde Google tiene su centro de desarrollo. “Ya pasamos la etapa más difícil, la de encontrar un socio capaz de brindarnos cobertura y precisión, algo que no sucede con otros países en la región donde la información no es tan precisa como en la Argentina”, dijo.

A ese motivo adjudicó la demora en incorporar la información de la Argentina en Google Maps.

Para diferenciarse del resto de los mapas disponibles, como los de Microsoft, Google incorporó un elemento muy útil: la dirección de las calles.

En una segunda etapa, que se pondrá en marcha entre fin de año y los primeros meses de 2009, Google planea incorporar aún más funciones a sus mapas para la Argentina.

Entre ellas figuran la búsqueda de direcciones y cómo llegar de un lugar a otro. “Para decir que está lanzado en un 100% falta la búsqueda de comercios, estado del tránsito y el ruteo del transporte público”, dijo Quintella.

Por último, consultado sobre la posibilidad de la llegada a la Argentina de Street View, el sistema de imágenes callejeras, Quintella expresó que “la idea es hacerlo, pero estamos más cerca de que sea dentro de un año que en unos pocos meses”.

paterlinimatias Uncategorized ,

Great day at Fasta University

September 27th, 2008

Yesterday I presented a conference about facebook apps development at Fasta University.

It was a great time, and there are new oportunities to make the presentation in other companies and universities soon. There is a posibility to make a webcast too, so I’ll keep you informed about updates.

You can download the presentation here (it’s spanish mostly, english presentation coming soon):

http://www.paterlinimatias.com/presentations/fasta-2008.pptx

Thanks to all the devs that came to the conference, it was nice to share that time with you.

Cheers!!!

Matias Paterlini

paterlinimatias Development, Facebook, Open Social, Social Network, Uncategorized , , , , , ,

Making the world more social and connected.

August 18th, 2008

Hi there!,

I’ll be sharing with you new posts about different topics like social networks, tips and trics about new technologies that I hope will be useful for you.

You can contact me anytime you want!!.

Cheers

Matias Paterlini

PS: Coming soon the spanish version of this blog, thanks for waiting..

paterlinimatias Facebook, Social Network, Uncategorized