New web2py/pydal feautures for scalability

173 views
Skip to first unread message

Massimo Di Pierro

unread,
Aug 5, 2018, 9:43:00 PM8/5/18
to web2py-users
Some of you may not like using the filesystem for strong data. In particular that is not a good solution for scalability. Now you can do:

myconf = AppConfig(reload=True)
# always store sessions in cookies
session.connect(request, response, cookie_key=myconf.get('app.cookie_key'))
# store metadata tables in db
db = DAL(myconf.get('db.uri'),
         pool_size=myconf.get('db.pool_size'),
         migrate_enabled=request.is_local,  # trigger a migration when called locally
         fake_migrate_all=request.is_local and request.vars._fake, # trigger a fake migration when passing ?_fake=1
         adapter_args=dict(migrator=InDBMigrator), # store metadata tables in db itself
         check_reserved=['all'])

Notice that if you change your code to do this in an exiting app, you must run a fake migration.




Joe Barnhart

unread,
Aug 7, 2018, 3:21:09 PM8/7/18
to web2py-users
It took me a minute to decipher this post!  For the elucidation of others let me rephrase what I think you wrote...

Some users may not like STORING (not "strong") data in the filesystem.  Storing filesystem data is a bad idea when deploying the same website across multiple servers, i.e. it hinders "scalability" in web deployment.

You can now store the table definitions (currently in the "databases" directory of your web2py application) into the database itself.  This eases the problem of scaling the application at the cost of a little complexity.  First off, store "session" data on the user's web client by putting session data directly in the cookie.  Then configure DAL to store the "metadata" (i.e. "*.table" files) in the database itself, as shown below...

If I got it wrong, please let me know.

-- Joe

villas

unread,
Aug 10, 2018, 7:18:45 AM8/10/18
to web2py-users
This is a very welcome feature for scaling.
Thanks Joe for your super-helpful post,  I wish I had read it first!  :)
Reply all
Reply to author
Forward
0 new messages