PyCon Finland is almost here – why you should register now

PyCon Finland is arranged for the third time. This year you will find us at Otaniemi, near Helsinki, October 21st-23rd. The registration closes Oct 11th, so grab your tickets now.

(Disclaimer: I am one of the organizers)

ImageWe offer more sauna than all the other PyCons of the world combined: on the pre-conference night there is a sauna party. For foreign participants this in an excellent chance to learn more about this interesting side of the Finnish culture. Please note that the sauna in the picture is not related to this event.

Here are some other highlights besides the normal conference activities

Follow PyCon Finland (Facebook, Twitter, IRC, mailing list) to keep up-to-date!

See you there!

 

\"\" Subscribe to RSS feed Image Follow me on Twitter Image Follow me on Facebook Image Follow me Google+

Useful duckduckgo searches for developers

DuckDuckGo.com is a web search engine. The superior value of DuckDuckGo comes from its ability of doing specialized searches. For non-specialized searches it uses Bing as the generic web search backend. In this blog post I describe how you can optimize your web and software development workflow with DuckDuckGo and its specialized searches.

Bing is almost on par with Google for English search results. However, it still leaves much improvement for non-English search results like ones with my native language Finnish. Thus, one cannot use DuckDuckGo for your everyday searches, like for shopping in Finland. You still need to go to Google for those. To work around this issue I have dual search engine configuration in my Firefox.

Image

  • If I want to search from Google I type the search on the address bar (left side).
  • If I want a specialized search I type into the DuckDuckGo search box. (right side) You can install it for your browser from a button on the bottom right corner of duckduckgo.com.
  • Please note that this setup does not work with Safari which cannot do address bar searches.  Chrome also lacks the search box widget out of the box. There is something called Search Box for Chrome, but I have not tried to configure it for DuckDuckGo on Chrome (I use Chrome only as the web development browser).

Specialized searches

DuckDuckGo provides something called !bang syntax. You start your search query with a bang (!) and a keyword. In this case DuckDuckGo performs a special search, not a generic web search. Usually this means DuckDuckGo uses a site specific search engine skipping the web search altogether. Here are example queries which you will find very useful.

!mdn iframe – Search term iframe on Mozilla Developer Network. Useful for all HTML, CSS and Javascript related searches. MDN is the most hiqh quality information source for all web development related matters. Using this search skips low quality sites like w3schools.com. Also works: !javascript and !css.

Image

Example what happens when you search !mdn iframe in duckduckgo.com search box

!python socket – Search “socket” on docs.python.org for Python documentation. (no one remembers Python APIs)

!pypi vvv – Search a package named vvv on pypi.python.org (a validation and linting integration for your software development projects)

!jq offset – Search offset function in jQuery documentation

!gh sevabot – Search Github for projects called “sevabot” (It’s a very handy Skype bot with HTTP interface)

!so video canvas – Search stackoverflow.com questions related to “video” and “canvas” (how to draw HTML5 video frames on <canvas>)

!php open – Try to figure out how to open a file in PHP (there are always open positions in non-PHP related software development jobs if you feel your life is misery)

!man zsh – UNIX manual page for zsh command. (check also our tuned ZSH configuration)

!ubuntuforums zsh – Search ubuntuforums.com for threads related to ZSH

!yt wesibussi – Search YouTube videos called “wesibussi” (I was young and it was fun)

As you can see, you can also copy-paste the DuckDuckGo.com search link in chat (IRC) easily for less experienced peers to educate them how to do power searches.

For the full bang queries list see the official duckduckgo.com source. You will find useful pointers for other programming languages (Perl, Ruby, Java, C#, etc).

 

 

\"\" Subscribe to RSS feed Image Follow me on Twitter Image Follow me on Facebook Image Follow me Google+

Feedburner, Planet Venus and categorized posts

This post gives some insight for blog owners how to tune WordPress & Feedburner when  posting their posts to various open source planets / aggregation services.

Preface

Google’s Feedburner is a popular feed subscriber statistics service for blog owners. Planet Venus is popular feed aggregation service software used by many open source projects to create a website of gathered RSS feeds (an example).

WordPress is a popular blogging software and has a plug-in which will automatically enable feedburner statistics for all the feeds using HTTP redirects. For a blogger using the plug-in means painless set-up of Feedburner statistics on his/her blog.

Problem

Usually planets (the aggregation services) are only interest blog posts of a certain category (it this example let’s call the category “plone”). WordPress enables categorized RSS 2.0 feeds using URLs of the following syntax

http://opensourcehacker.com/category/plone/feed/

Then this URL is put into the configs of Planet Venus and Planet Venus starts aggregating posts of a certain category from the source blog.

Now, if the blog is feeding out both categorized posts AND is using a feedburner a problem rises. The feedburner redirects at the feedburner.google.com might not properly handle categorized feeds. Instead, you’ll get an error page saying “looks like your computer might be doing too much automated requests” or something along the line.

Solution

Luckily there is an easy fix. In the WordPress Feedburner plug-in settings tick the following option:

Settings -> Feedburner ->

This should allow the aggregators to gather the categorized posts and still use Feedburner stats for the users who subscribe the main RSS feed or your blog.

 

\"\" Subscribe to RSS feed Image Follow me on Twitter Image Follow me on Facebook Image Follow me Google+

Google App Engine: issues with dynamic instances and DeadlineExceededErrors

Dynamic instances and processing time

This Google App Engine feature came me as a surprise, though it makes perfect sense. Your site is slow if it has low traffic.

Google App Engine runs Python code on instances. By default, instances are dynamic. Instances are shutdown if they do not have enough traffic (requests per minute). Thus, when you get the individual hits to App Engine now and then, App Engine must restart your instance every time for each hit.

When this happens, you see the following in App Engine console logs for every request on low volume traffic:

This request caused a new process to be started for your application,
and thus caused your application code to be loaded for the first time.

It is not always ok to add 500 – 2000 milliseconds processing delay on the top of the normal processing time. Google’s own recommendation was that each page should be served within 200 milliseconds.

There are three ways to optimize this issue

  • Use App Engine premium feature “Always on” 0,30 $ / day which keeps your instance always running
  • Use cron job or such to keep your instance alive (polling once in a minute seems to do the job)
  • Optimize your imports and split your code to several modules with light amount of imports, so that start up is fast (modules are imported only once)

We are using Zabbix software to monitor our sites (sidenote: I don’t recommend Zabbix as the first monitoring software choice as it is very difficult to use and has bad user experience, alienating both sysadmins and developers away from it). This is what we had before optimizations – App Engine was starting a new process for every request:

Image

… and this is output we got after optimizations:

Image

Here is the corresponding diagram after optimizations from App Engine dashboard itself. These processing times are without network latency. As far as I know Google does not expose the endpoints of App Engine hosting, so you don’t know from which site of the world your responses come from. By comparing this diagram to the diagram above, you can see how Internet traffic is affecting to your App Engine application.

Image

The PITA of dying instances

For some reason, App Engine instances misbehave sometimes. This causes the HTTP requests die ungracefully.

Normally it is not a problem as you lost few page loads now and then. People are used to “Internet grade” service and can hit the refresh button if they have problems opening a page.

However if you are monitoring your site and the site gives an unnecessary alarm in the middle of the night, waking up your bastard operator from Hell, he will be very angry next morning and tell you to migrate the crappy software from unreliable Python / App Engine to more reliable PHP servers 🙁

This is what you see in App Engine logs:

A serious problem was encountered with the process that handled this request, causing it to exit.
This is likely to cause a new process to be used for the next request to your application.
If you see this message frequently, you may be throwing exceptions during the initialization of your application. (Error code 104)

After digging in deeper, you see that it is a problem of instating a new object in the database, exceeding 30 seconds hard limit for processing a HTTP request:

2011-03-09 05:06:20.794 / 500 30094ms 86cpu_ms 40api_cpu_ms
0kb Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
.NET CLR 2.0.50727),gzip(gfe),gzip(gfe),gzip(gfe)

<class 'google.appengine.runtime.DeadlineExceededError'>:
Traceback (most recent call last):
  File "/base/data/home/apps/mfabrikkampagne/1.347249742610459821/main.py", line 494, in main
    run_wsgi_app(application)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 97, in run_wsgi_app
    run_bare_wsgi_app(add_wsgi_middleware(application))
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 115, in run_bare_wsgi_app
    result = application(env, _start_response)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 515, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/mfabrikkampagne/1.347249742610459821/main.py", line 296, in get
    try: self.session = Session()

So it looks like there is a temporary hick-up in Google App Engine’s Data Store (Big Table?). In the example above the error comes from gaeutilities‘s Session model, but it could be any other model.

It is possible to catch DeadlineExceededError and temporarily work-around it, as shown in App Engine documentation.

The best way to handle this situation is to adjust your monitoring software – Zabbix in our case. Zabbix allows you to configure triggers so that they don’t alarm on every bad item state change. Instead, you can use min() function and trigger the alarm after the trigger condition has failed every time during a monitoring period. Just make sure that the trigger period is at least twice long as the update interval of your web scenario: this way Zabbix can logs at least two item state changes and allows one of them to be failed one.

For example if

  • Update interval of web scenario is 60 seconds
  • Trigger function must check minimal failures of 1 during 2*60 seconds + some buffer = 150 seconds.
{xxx.fi:web.test.fail[de.mfabrik.com].min(150)}=1

This will allow one failed response before triggering the alarm.

\"\" Subscribe to RSS feed Image Follow me on Twitter Image Follow me on Facebook Image Follow me Google+