Here are the key approaches to caching in Django:
- Per site caching (generic approach) - Cache entire pages without GET/POST parameters and only for anonymous users.
- Per view caching (granular approach) - Cache responses of individual views by decorating them with @cache_page and setting timeouts.
- Template fragment caching (micro manage approach) - Cache fragments of templates, both static and dynamic, by using the {% cache %} tag and specifying keys.
- Low level caching (micro micro manage) - Cache individual parameters by storing and retrieving from the cache backend directly in the views.
The level of caching ranges from generic site-wide caching to fine-grained fragment caching. Per view and
An overview of the Django rapid application development framework. Topics include the history of the framework, an architectural overview, how to get started, and a brief comparison to Ruby on Rails.
Slides from our CodeMash 2013 Precompiler session, "Web Development with Python and Django", including a breezy introduction to the Python programming language and the Django web framework. The example code repository is available at https://github.com/finiteloopsoftware/django-precompiler/
An overview of the Django rapid application development framework. Topics include the history of the framework, an architectural overview, how to get started, and a brief comparison to Ruby on Rails.
Slides from our CodeMash 2013 Precompiler session, "Web Development with Python and Django", including a breezy introduction to the Python programming language and the Django web framework. The example code repository is available at https://github.com/finiteloopsoftware/django-precompiler/
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesTikal Knowledge
Django is a Python Web Framework gaining popularity among developers all over the world, due to its power & simplicity. In this session we will describe what makes the framework so attractive, and why you should consider it for your next Web application.
Presentation & Featured Video in Full Version.
This is the slides I used when I shared my humble insight on Django to the students in University of Taipei in 2016. Please feel free to correct me if there is anything wrong.
More and more web projects require interfacing with the backend using a REST-ful interface. In this presentation we'll discuss Django-REST-Framework's features and walk through how to integrate it into your next project!
This text presentation attempts to hit on the highlight features and structure of Django and its ecco-system. It is intended as an introduction for those who are curious about , what is it?
A brief introduction to using Apache Solr for implementing search for your website.
Download the ppt to see comments which add more detail.
Presented at eBig Java SIG, Oakland, CA. June 2008
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesTikal Knowledge
Django is a Python Web Framework gaining popularity among developers all over the world, due to its power & simplicity. In this session we will describe what makes the framework so attractive, and why you should consider it for your next Web application.
Presentation & Featured Video in Full Version.
This is the slides I used when I shared my humble insight on Django to the students in University of Taipei in 2016. Please feel free to correct me if there is anything wrong.
More and more web projects require interfacing with the backend using a REST-ful interface. In this presentation we'll discuss Django-REST-Framework's features and walk through how to integrate it into your next project!
This text presentation attempts to hit on the highlight features and structure of Django and its ecco-system. It is intended as an introduction for those who are curious about , what is it?
A brief introduction to using Apache Solr for implementing search for your website.
Download the ppt to see comments which add more detail.
Presented at eBig Java SIG, Oakland, CA. June 2008
Django makes it so easy to get started; ``manage.py runserver`` and away you go. But deploying an application so that the system can provide redundancy and scalability requires some heavier lifting: package installs, configuration settings, multiple servers, security, backups, etc.
Ansible is a python-based configuration management tool which helps automate and repeat deployments whether the hardware is local or in the cloud. We'll be covering how to leverage existing configurations, write your own and sharing best practices for deploying django applications.
Django is a free and open source web application framework, written in Python, which follows the Model–View–Controller architectural pattern.
It focuses on automating as much as possible and adhering to the DRY principle
Does Django scale? How to manage traffic peaks? What happens when the database grows too big? How to find (and fix) the bottlenecks?
We will overview the basics concepts, we'll use metrics to find bottlenecks, and finally we'll see some tips and tricks to improve the scalability and the performance of a Django project.
Main topics:
- System architecture
- Database performance
- Finding bottlenecks
- Monitoring, profiling, debugging
- Query optimization
- Dealing with a slow admin
- Queues and workers
- Faster tests
Talk given at #EuroPython 2016: https://ep2016.europython.eu/conference/talks/efficient-django
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)Doris Chen
Get frustrated by cross-browser incompatibility? Hate to develop application using JavaScript? jQuery is a powerful JavaScript library that can enhance your websites regardless of your background. jQuery is fast, lean, simple and hugely expandable, enabling you to build compelling web applications quickly and easily. In this session, we will start with a quick introduction of jQuery, illustrate what’s so good about jQuery, and demonstrate step by step how to develop jQuery Ajax application efficiently with database, web services, OData, NetFlix and ASP.NET MVC. Microsoft is now shipping, supporting, and contributing to jQuery, with ASP.NET and Visual Studio. New features which will be available in the next release of jQuery such as globalization, templating and data-linking will be introduced in the session as well.
Whether you are building a mobile app or a web app, Apache Usergrid (incubating) can provide you with a complete backend that supports authentication, persistence and social features like activities and followers all via a comprehensive REST API — and backed by Cassandra, giving you linear scalability. This session will tell you what you need to know to be a Usergrid contributor, starting with the basics of building and running Usergrid from source code. You’ll learn how to find your way around the Usergrid code base, how the code for the Stack, Portal and SDKs and how to use the test infrastructure to test your changes to Usergrid. You’ll learn the Usergrid contributor workflow, how the project uses JIRA and Github to manage change and how to contribute your changes to the project. The session will also cover the Usergrid roadmap and what the community is currently working on.
TypePad Motion is a Django web application for creating community microblogging sites. It uses the TypePad API as a backend data store, so you don't have to worry about scaling, backups, or any related infrastructure. All you need is a web server.
(BDT402) Performance Profiling in Production: Analyzing Web Requests at Scale...Amazon Web Services
Code profiling gives a rich, detailed view of runtime performance. However, it's difficult to achieve in production: for even a small fraction of web requests, huge challenges in scalability, access, and ease of use appear. Despite this, Yelp profiles a nontrivial fraction of its traffic by combining Amazon EC2, Amazon EMR, and Amazon S3. Developers can search, sort, filter, and combine interesting profiles; during a site slowdown or page failure, this allows a fast diagnosis and speedy recovery. Some of our analyses run nightly, while others run in real-time via Storm topologies. This session includes our use cases for code profiling, its benefits, and the implementation of its handlers and analysis flows. We include both performance results and implementation challenges of our MapReduce and Storm jobs, including code overviews. We also touch on issues such as concurrent logging, cross-data center replication, job scheduling, and API definitions.
This presentation shall address the web2py web framework, my favorite way to develop web apps.
web2py is a free, open-source web framework for agile development of secure database-driven web applications; it is written in Python and programmable in Python. web2py is a full-stack framework, meaning that it contains all the components you need to build fully functional web applications.
Ease of use is the primary goal for web2py. For us, this means reducing the learning and deployment time. This is why web2py is a full-stack framework without dependencies. It requires no installation and has no configuration files. Everything works out of the box, including a web server, database and a web-based IDE that gives access to all the main features.
I will show you why web2py can make you more productive by bringing the result of a reflection over the best ideas of the most popular MVC based web frameworks enforcing the best practices for a fast, scalable and secure web application with minimal effort. There will be a live demo where you can get a faster grasp on how does it work and how fun it can be.
For more: www.web2py.com
How to generate customized java 8 code from your databaseSpeedment, Inc.
Did you know that database classes, that require many lines of Java and SQL code, may be replaced with a single line of Java 8 code? In this tutorial session you will learn how to use standard Java 8 Streams as an alternative to traditional Object Relational Mappers (ORM). We will use the open-source tool Speedment to show how development speed can be increased and how the application code can be more concise and run faster.
Silicon Valley JUG - How to generate customized java 8 code from your databaseSpeedment, Inc.
The best code is the one you never need to write. Using code generation and automated builds you can minimize the risk of human error when developing software, but how do you maintain control over code when large parts of it is handed over to a machine? In this tutorial, you will learn how to use open-source software to create and control code automation. You will see how you can generate a completely object-oriented domain model by automatically analyzing your database schemas. Every aspect of the process is transparent and configurable, giving you as a developer 100% control of the generated code. This will not only increase your productivity, but also help you build safer and more maintainable Java applications.
Talk at RubyKaigi 2015.
Plugin architecture is known as a technique that brings extensibility to a program. Ruby has good language features for plugins. RubyGems.org is an excellent platform for plugin distribution. However, creating plugin architecture is not as easy as writing code without it: plugin loader, packaging, loosely-coupled API, and performance. Loading two versions of a gem is a unsolved challenge that is solved in Java on the other hand.
I have designed some open-source software such as Fluentd and Embulk. They provide most of functions by plugins. I will talk about their plugin-based architecture.
3. Installing libraries
• Always work in a virtualenv
$ pip freeze
# ONE GAZILLION LIBRARIES!!!!
(inuittest)$ pip freeze
argparse==1.2.1
wsgiref==0.1.2
(inuittest)$ pip install yolk django south
(inuittest)$ yolk –l
Django - 1.4.2 - active
Python - 2.7.3 - active development
(/usr/lib/python2.7/lib-dynload)
South - 0.7.6 - active
argparse - 1.2.1 - active development (/usr/lib/python2.7)
pip - 1.2.1 - active
setuptools - 0.6c11 - active
wsgiref - 0.1.2 - active development (/usr/lib/python2.7)
yolk - 0.4.3 - active
7. Architecture
RDBMS
Storage ORM Fixtures
Model
Signals
Forms
Template
URL Resolver View Template Loader
Middleware Middleware
Request Response
8. Model
RDBMS
Storage ORM Fixtures
Model
Signals
Forms
Template
URL Resolver View Template Loader
Middleware Middleware
Request Response
9. Model
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
10. Model
BEGIN;
CREATE TABLE "polls_poll" (
"id" serial NOT NULL PRIMARY KEY,
"question" varchar(200) NOT NULL,
"pub_date" timestamp with time zone NOT NULL
);
CREATE TABLE "polls_choice" (
"id" serial NOT NULL PRIMARY KEY,
"poll_id" integer NOT NULL REFERENCES "polls_poll" ("id") DEFERRABLE INITIALLY
DEFERRED,
"choice" varchar(200) NOT NULL,
"votes" integer NOT NULL
);
COMMIT;
12. Request Response Cycle
1. Determine which URLConf to use
2. Load that URLConf and look for
urlpatterns variable
3. Run through each pattern in order and stop
at the one that matches
4. Once a match is found, import and call the
view with the HttpRequest object
5. If no regex matches or an exception is raised,
invoke error-handling
32. Application Server (AS)
Web Server Gateway Interface (WSGI)
• PEP 333 [P. J. Eby, dec 2010]
• Common ground for portable web applications
– Routing, environment variables, load balancing,
forwarding, post-prosessing
• 2 parts:
– Gateway (= server)
– Framework (= application)
33. AS: gunicorn
• “green unicorn” (cfr. green threading)
• Pre-fork worker model
• 4-12 workers = 1000’s req/sec
• Each worker runs an instance of your django
project => memory
34. AS: uWSGI
• Protocol “uwsgi” (lowercase)
• Included in Nginx & Cherokee
• Faster than gunicorn
36. Tools
• IPython
– Tab completion in the interpreter!
• import ipdb; ipdb.set_trace()
– Just like pdb, but with added magic
• Fabric (fabfile.org)
– $ fab production deploy
– Like Capistrano but without the voodoo
• Supervisord (supervisord.org)
– Process monitoring & controlling
39. Cache Systems
CACHE_BACKEND = ....
– Dummy caching
• ‘dummy:///’
• For development, dummy!
– Local-Memory Caching
• ‘locmem:///’
• In memory caching without memcache
– Database Caching
• ‘db://my_cache_table’
• When DB I/O is not a problem.
– Filesystem Caching
• ‘file:///var/tmp/django_cache’ # directory
• Cache values stored in seperate files in pickled format
– Memcache
• ‘memcached:///127.0.0.1:112211/’
40. Approaches to Caching
• Per site caching (generic approach)
– Only cache everything without GET or POST parameters
– Only cache anonymous requests
• Per view caching (granular approach)
– Cache response of a view
– Set cache timeouts per view
• Template Fragment caching (micro manage approach)
– Caching both static and dynamic fragments
• Low level caching (micro micro manage)
– Indivudually store parameters in the cache
42. Approaches to Caching
• Per site caching (generic approach)
– Only cache everything without GET or POST parameters
– Only cache anonymous requests
• Per view caching (granular approach)
– Cache response of a view
– Set cache timeouts per view
• Template Fragment caching (micro manage approach)
– Caching both static and dynamic fragments
• Low level caching (micro micro manage)
– Indivudually store parameters in the cache
44. Approaches to Caching
• Per site caching (generic approach)
– Only cache everything without GET or POST parameters
– Only cache anonymous requests
• Per view caching (granular approach)
– Cache response of a view
– Set cache timeouts per view
• Template Fragment caching (micro manage approach)
– Caching both static and dynamic fragments
• Low level caching (micro micro manage)
– Indivudually store parameters in the cache
45. Approaches to Caching
• Per site caching (generic approach)
– Only cache everything without GET or POST parameters
– Only cache anonymous requests
• Per view caching (granular approach)
– Cache response of a view
– Set cache timeouts per view
• Template Fragment caching (micro manage approach)
– Caching both static and dynamic fragments
• Low level caching (micro micro manage)
– Indivudually store parameters in the cache
46. {% load cache %}
{% cache 500 sidebar request.user.username %}
.. sidebar for logged in user ..
{% endcache %}