Performance Improvement Question

Jun 29, 2007 at 12:28 PM
I was wondering what I can do to improve the performance of my ASP.NET/Facebook application. Is it ok to store the FacebookService object in the session variables for the user? Is it ok to store the Friends list in the session variables? Can anything else be safely cached? It just seems that no matter what I do, or even if I have just a blank page with the FacebookService object on it, my application isn't nearly as fast as any of the other Facebook applications. I know I have a good hosting company and my server has more than enough horsepower, everything else (non-facebook) runs lightning fast. Any thoughts would be much appreciated.

Thanks!
Jon
Coordinator
Jun 29, 2007 at 2:19 PM
Can you add tracing to your application to determine what the bottleneck is? I don't know why blank page would be slow. We can definitely look into improvements if some are identified.

The only thing I can think of is whether you are pre-compiling your page. If not, the first hit to your page will cause the code-behind(s) to be compiled, which could cause what you are seeing. But, this should only happen on the first hit.
Jul 3, 2007 at 3:50 PM
Sorry for the vague problem description. I have enabled caching of the FacebookService object and the application seems much, much faster now. Previously I was calling the FacebookService.CreateSession on every page load, now I just call it on the initial page load and put it into the application cache. Is there anything wrong with this approach? Is there something that I might be missing that could cause problems later on?

Thanks!
Jon
Coordinator
Jul 3, 2007 at 4:13 PM
Nope. I think that is fine. In my IFRame base pages and Web Sample I propose putting it in Session. The only downside is making sure to capture when someone's facebook session is timed out. In that case the FacebookService methods will fail (even though you have session info in your application cache.
Oct 23, 2007 at 2:36 PM
{"

Hi, I have serious performance problem in my IFrame based Facebook application.

I have tried to cache fbService to Application Cache. It increased the performance but the problem is, tha cached FBService , returned the firstly loggedin fb user id. Should I cache it in session object?
Another point is, I enabled tracing and found out that main bottleneck is GetFriendsAppUsers() function. It takes approx. 10 sec. I replaced it DirectFQLQuery but it just changed 2 or 3 seconds.
So I dont know what to do.
I have to use IFrame. Actually, every time I used Datalist, or other .NET controls, in FBML canvas pages, I got error.

As I experienced, FBML has a static performance. But in IFrame, if your web server, internet line speed and also DB are good enough, you can take a good output.

my Current situation is: because I couldn't find a way, I put my app as it is. I mean 15 sec. needs to load.

Is there any advise?
Thanks

"}
Developer
Oct 24, 2007 at 7:39 PM
FacebookService is intended to be used for a single user session, since it maintains connection information for that user's session. That's why none of the methods take any kind of currentUser parameter - FacebookService stores that internally. So yes, you'll want to cache it in the session object, so that each of your users has their own FacebookService whenever they are logged in to your application.

As for your issue with GetFriendsAppUsers, that's just a result of the design of the Facebook platform. If you get all information about every friend using the app (which is what GetFriendsAppUsers does), it takes Facebook a while to respond if there are a lot of records (say, 100 or more) to return. However, if you want to speed things up, it seems that even with the same number of records, if you select less fields from the user info, then your query will speed up significantly. You may have to play around with it a bit to figure out what slows down and what doesn't, but my advice to you is to do a DirectFQL query on only the information you need.

Just two other questions: What sort of error did you get when you used .Net controls in FBML (and what exactly were you doing with the controls), and what do you mean by "static performance" with FBML?