Just thoughts

Wednesday, May 19, 2010

Google Appengine- free service, not good for anything

At least for me. I didn't have too much mood to try it out but since everyone was so "wow" about it, why not.
But what should I do, what should be the first project?! Let's create a chat!

GAE Chat
What can be so hard in creating a chat on Appengine using Python? Ajaxy GUI, Google Single Sign-on, free, fast database... it should rock on, shouldn't it? I tell you what, it won't.
If you're not clever enough, even with two users chatting you hit a limit. Not Datastore calls, not number of requests... but CPU Time! You have the fastest servers you can imagine and what happens when you run an AJAX chat? You hit the wall cos you have such a generous quota set.

GAE Audio/Voice Chat
This is neither hard considering that Java has a massive, powerful Sound API. In fact, you can create such a service with not more than 50 lines of Java call and two classes.
Hoho... hold it back; it's not so easy if you want to use GAE! You didn't observe that GAE has no support for the Sound API, did ya? Creating an Audio Chat on Appengine = Failure.

GAE Crawler
How about automated crawling of a forum? I want stats, I have to extract data from URLocations. In PHP 100 lines of code the most, with database CREATE calls altogether so with the powerful Python or Java it should be a piece of cake. Especially since you have such a simple GQL syntax.
Nah, you won't automate your crawler... you hit a frigging limit again! It turns out that Google allmighty ain't likes too many content on forums... there are too many URIs to be crawled. So what, just damn crawl it.

GAE URLFetch


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.*;

@SuppressWarnings("serial")
public class html_fetcherServlet extends HttpServlet {
    private String line;

    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {
        resp.setContentType("text/html");
        try {
            if(req.getParameter("uri") != null){
                URL url = new URL(req.getParameter("uri"));
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                connection.setDoOutput(true);
                connection.setRequestMethod("GET");
                connection.setRequestProperty("User-Agent", "My UA");

                 String urlenc = URLEncoder.encode(req.getParameter("uri"), "UTF-8");
                 connection.setRequestProperty("Referer", "http://www.google.com/url?sa=t&source=web&ct=res&cd=7&url=" + urlenc + "&ei=0SjdSa-1N5O8M_qW8dQN&rct=j&q=flowers&usg=AFQjCNHJXSUh7Vw7oubPaO3tZOzz-F-u_w&sig2=X8uCFh6IoPtnwmvGMULQfw");

                connection.setInstanceFollowRedirects(false);

                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                Map responseMap = connection.getHeaderFields();
                int i = 1;
                                     
               for (Iterator iterator = responseMap.keySet().iterator(); iterator.hasNext();) {
                    String key = (String) iterator.next();
                    resp.getWriter().println(key + " = ");

                    List values = (List) responseMap.get(key);
                    for (int i1 = 0; i1 < values.size(); i1++) {
                        Object o = values.get(i1);
                        resp.getWriter().println(o + "");
                    }
                }
                resp.getWriter().println("
");
                while ((line = reader.readLine()) != null) {
                    resp.getWriter().println(i + " " + escapeHtmlFull(line));
                    i++;
                }
                resp.getWriter().println("
");
                reader.close();
            }
        } catch (MalformedURLException e) {
            resp.getWriter().println(e.getMessage());
        } catch (IOException e) {
            resp.getWriter().println(e.getMessage());
        }
    }


public static StringBuilder escapeHtmlFull(String s){
}


Simple, isn't it? Set some headers, referer and user-agent then get the remote page... hard? No.
Google says... Hold on Sparky! You won't do that, will ya?! No I won't cos the allmighty doesn't let me to do it. Better said, it does, but it frigging appends its own User-Agent to mine just to show off how cool we are! I tell you what: I need my own user agent cos it's my frigging app, not yours! The app has to have correct user agent set by me, else it has no meaning creating it. And when do I learn about that you'll append your crap to my crap? On the production server; locally works fine.

Did I finish whining? Nope.

GAE Sitemap checker
How about uploading some XSDs as static files with my app and let the webmasters test their sitemaps against those XSDs? It's a cool app and is for the humanity.
Not so fast (again)! You can't open your own files for READING through Java on Appengine (probably with Python neither). Your own files...


So, why I'm not paying for this service and have some limits lifted?
After all these experiences? Hell no. I was told it's free. If I will pay for a cloud computing service, that will be EC2. Just because they didn't let me fall in false assumptions like I get top-notch service for free...

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home