Showing posts with label web-apps. Show all posts
Showing posts with label web-apps. Show all posts

Sunday, January 11, 2015

Good HN thread on scaling a web app to 10K users

By Vasudev Ram




Saw this today on Hacker News:

What does it take to run a web app with 5K – 10K users?

I read the thread. Found that it had a number of good comments, on both sides of the equation - the business side, i.e. acquiring, retaining and supporting users, and the technical side, i.e. scaling the hardware and software to manage the load on the app. Many of the people who commented, run their own web apps at the same or higher scale.

Overall, a worthwhile read, IMO.

- Vasudev Ram - Dancing Bison Enterprises

Signup to hear about new products or services from me.

Contact Page

Friday, February 7, 2014

Interesting site - Full Stack Python

By Vasudev Ram

Saw this on the Net today.

Full Stack Python.

The creator of the site, Matt Makai, is a developer evangelist for Twilio and describes himself as a full stack developer.

Browsed it for a bit. Full Stack Python is a site that talks briefly (with links to more information) about various aspects and layers of the stack (from hardware/servers up to web frameworks, with VPS, IaaS and PaaS in between) that you need to know about / use when developing applications or products with Python for the Web.

Full Stack Python does seem to cover many of the topics that a developer or an organization using a Python stack for Web development needs to know about, but the amount of information under some of the topics seems to be a bit low or sketchy, considering how many options there are at many layers of the stack. However, it is a good effort.

Update: Here is a Python Reddit thread about Full Stack Python. There are many comments on it.

- Vasudev Ram - Dancing Bison Enterprises

Contact Page

Friday, November 15, 2013

A basic WSGI PDF server


By Vasudev Ram

Humpty Dumpty

While browsing the Python Reddit, I saw this post:

Python website tuts that don't use Django, in which the poster (user amnion) asked (excerpted for brevity):

"I'm trying to get a feel for how Python can be used for websites ... I want to familiarize myself with everything under the hood more. ... any resources that show how to make a website without using a framework?"

Many of the answers were interesting (and some had useful links to related reading), but I found this one particularly of interest (user name showed as [deleted] for some reason):


Here's a basic wsgi server (aka "enough to make a website without using a framework").

The variables path and method will contain the path portion of the requested url and the http verb (GET, POST...). "Real" web frameworks are built up around this interface, adding features for url routing, authentication, session management, persistence, etc.

Sans framework, you're free to produce html in any way you see fit. This ten line example runs on python's simple http server, but it will also run on apache/ mod_wsgi, google app engine, or anything supporting wsgi.

"""
basic_wsgi_server.py
Basic WSGI server in Python.
From: http://www.reddit.com/r/Python/comments/1eboql/python_website_tuts_that_dont_use_django/c9z3qyz
"""

from wsgiref.simple_server import make_server

host = 'localhost'
port = 8888

def app(environ, start_response):
    path = environ['PATH_INFO']
    method = environ['REQUEST_METHOD']

    response = 'This is the page for "{}"'.format(path)

    start_response('200 OK', [('Content-type', 'text/html')])
    return [response]

make_server(host, port, app).serve_forever()

I tried the above code (I named it basic_wsgi_server.py), and it worked.

Then, out of interest, I thought of modifying that basic WSGI server to make it serve PDF, using my xtopdf toolkit for PDF creation. Constant PDF content, though, not dynamically generated stuff. So here is the code of basic_wsgi_pdf_server.py:

# Basic WSGI PDF server in Python.
# Adapted from:

# http://www.reddit.com/r/Python/comments/1eboql/python_website_tuts_that_dont_use_django/c9z3qyz

from debug1 import debug1
from PDFWriter import PDFWriter
from wsgiref.simple_server import make_server

host = 'localhost'
port = 8888

def app(environ, start_response):
    debug1("Entered app")
    path = environ['PATH_INFO']
    method = environ['REQUEST_METHOD']
    print "path:", path
    print "method:", method

    #response = 'This is the page for "{}"'.format(path)

    lines = [
            "Jack and Jill went up the hill",
            "Humpty Dumpty sat on a wall,",
            "'You are old, Father William,' the young man said,",
            "Master of all masters"
            ]

    debug1("Before creating PDFWriter and setting its fields")
    pdf_filename = "Nursery-rhymes-and-stories.pdf"
    pw = PDFWriter(pdf_filename)
    pw.setFont("Courier", 12)
    pw.setHeader("Excerpts from nursery rhymes and stories")
    pw.setFooter("Generated by xtopdf and basic_wsgi_pdf_server")

    debug1("Before for loop to write the lines")
    for line in lines:
        pw.writeLine(line)
        pw.writeLine(" ")
    pw.close()

    debug1("Before with statement to read file contents")
    with open(pdf_filename, "rb") as fil:
        response = fil.read()

    #start_response('200 OK', [('Content-type', 'text/html')])
    debug1("Before start_response")
    start_response('200 OK', [('Content-type', 'application/pdf')])
    debug1("Before returning response")
    return [response]

debug1("Before make_server and serve_forever()")
make_server(host, port, app).serve_forever()

Ran it with:

python basic_wsgi_pdf_server.py

Note that I added a few calls to a function called debug1, which is a slightly improved version of the debugging function I mentioned in this post:

A simple Python debugging function

, in order to proactively get information about any problem with the program. But it turned out to have no issues - worked straightaway.

Here is a screenshot of the output:


References:

[1] Jack and Jill
[2] Humpty Dumpty
[3] Father William
[4] Master of all masters

Isn't my test data better than Lorem ipsum? :-)

- Vasudev Ram - Dancing Bison Enterprises





O'Reilly 50% Ebook Deal of the Day

Wednesday, January 2, 2013

Using Go to create web apps - post and threads

Thoughts on Go after writing 3 websites : programming

First saw it on Hacker News.

The above thread is on Reddit.

Interesting stuff.

Sunday, October 7, 2012

Stylizer, real-time CSS editor integrated with 9 browsers


Stylizer is a CSS editor that integrates with 9 browsers and lets you make and see changes in real time. They seem to have Sony, IBM and Thomson Reuters as customers, among others (going by the logos at the bottom of their home page).

On their site: "Real-time CSS Editing Saves Time and Money."

The site is visually impressive, IMO.

Stylizer features.

It seems to be a paid app, but you can download Stylizer to try it out.


- Vasudev Ram - Dancing Bison Enterprises

Wednesday, June 6, 2012

Bottle Python framework is useful for small web apps

By Vasudev Ram









Bottle is a small Python web framework.



It can be useful for creating small / experimental web apps in Python.

It's easy to get started with. Installation is simple.

Creating small apps is also fairly easy.

The Hello World app is just this:

from bottle import route, run

@route('/hello/:name')
def index(name='World'):
    return 'Hello %s!' % name

run(host='localhost', port=8080)

I have been trying it out over the last few days and found it a good fit for the uses described above.

Like many web frameworks these days, it comes with a built-in development web server, so you don't have to spend time fiddling around trying to make it work with Apache or other servers - at least, not until you are ready to deploy your app in production.

Actually, as per the docs, running Bottle with CherryPy, Fapws3, Flup or Paste is simple. For example, this is how to use Paste (and it's similar for the others):

from bottle import PasteServer
...
run(server=PasteServer)

And the docs specify how to make it work on Apache with mod_wsgi.

I like the way the routes (URL-to-function mappings) are specified in Bottle.


- Vasudev Ram - Dancing Bison Enterprises

Tuesday, October 11, 2011

Dart from Google, a structured web programming language

By Vasudev Ram - dancingbison.com | @vasudevram | jugad2.blogspot.com

Google has just released the first public version of Dart, a new language, meant for what they call "structured web programming".

They had announced that they were working on Dart some weeks / months earlier.

The Dart language site is here: http://www.dartlang.org

It has an introduction to Dart, and links to a tutorial and a technical overview, among other things.

There is already a Dart thread on Hacker News, with tons of comments, some pro, some con:

http://news.ycombinator.com/item?id=3092558

Google says that the language can be used in most modern browsers - Chrome, Safari 5+, Firefox 4+, as well as on servers.

The site http://www.dartlang.org/ currently has an app called Dartboard.

Dartboard allows you to run a few sample snippets of Dart code.

It also lets you modify them and then run the modified versions.

I tried out the 4 or so sample Dart snippets in a recent Chrome version.

All samples worked. But running the code seemed to trigger web requests, even though the code itself was not doing anything web-related, as far as I know.

Not sure why, as of now. Possibly it is because the Chrome version I used does not yet support Dart, so clicking Run may be sending a request to the server to compile the Dart code into JavaScript and send it back to the browser to be run - Google does say that that is the way in which Dart will be able to run on browsers that _do not_ have explicit support for it.

Posted via email

- Vasudev Ram @ Dancing Bison

Friday, August 12, 2011

Google Chrome Beta to support C and C++ via Native Client - NaCl

By Vasudev Ram - dancingbison.com | @vasudevram | jugad2.blogspot.com

Seen on ReadWriteWeb and TechCrunch.

Some of the benefits claimed for Native Client (NaCl) are better performance via leveraging modules written in C and C++ in your web apps, re-using legacy code written in those languages (and there is, of course, tons of that around, though some parts may have to be modified to work with NaCl), and all this, while still maintaining security, due to the "double sandbox" model that NaCl apps will use.

NaCl is the chemical formula for common salt, and in a Google-ish play on words, the API that developers will use to create such apps is called the Pepper API.

Excerpts:

[ Native Client allows C and C++ code to be seamlessly executed inside the browser with security restrictions similar to JavaScript. Native Client apps use Pepper, a set of interfaces that provide C and C++ bindings to the capabilities of HTML5. As a result, developers can now leverage their native code libraries and expertise to deliver portable, high performance web apps. ]

The links to the articles:

Google Chrome Beta Now Supports C/C++:

http://www.readwriteweb.com/cloud/2011/08/google-officially-announces-cc.php

Google Unleashes Native Client Into Chrome, Next-Gen Web Apps To Follow?

http://techcrunch.com/2011/08/11/chrome-native-client/

The Google announcement about NaCl support:

http://chrome.blogspot.com/2011/08/building-better-web-apps-with-new.html

Posted via email
- Vasudev Ram @ Dancing Bison