django mod_wsgi, nginx MySQL or Postgres - mysql

I am looking to find out from the community which you think is best?
Django running with the following.
Django, mod_wsgi and MySQL
Django, mod_wsgi and Postgres
Django, nginx and MySQL
OR
Django, nginx and Postgres
?

I use nginx because it's faster and I like how the configuration is set up. I have never run into any trouble using it so I can't see why one should rather use Apache + mod_wsgi.
Also, using fastcgi, you can restart your django site without restarting the whole nginx server, which I like.
And Postgres because:
If you're not tied to any legacy system and have the freedom to choose a database back-end, we recommend PostgreSQL, which achives a fine balance between cost, features, speed and stability. (The Definitive Guide to Django, p. 15)
Copied from: MySQL vs PostgreSQL? Which should I choose for my Django project?
EDIT:
I now think that uwsgi running behind a load balancer (varnish) is the best solution. nginx can then be used to serve static content.
See "Varnish and nginx, the best way (0.9.8.4)" # http://projects.unbit.it/uwsgi/wiki/Example
You can use Emperor ( http://projects.unbit.it/uwsgi/wiki/Emperor) for managing apps in uwsgi. This will allow you to restart individual apps by simply touching their config files.

According to this benchmark Django+ uWSGI wins.

You can use nginx as a proxy and have apache run on localhost.
To start a single django project, you'd touch the wsgi file for that project and it will only reload that instance of django. You don't need to restart/reload apache

Related

Deploy my Flask app to Heroku using my own MySQL server

I have a project with a Flask backend and Vue frontend. I want to deploy it to Heroku but using my own MySQL database from my own MySQL server, without using Heroku's dynos.
Is this possible?
That depends what you mean by
my own MySQL database from my own MySQL server, without using Heroku's dynos
If your MySQL server is accessible from the Internet, sure. Just point your application at it.
(Note that using one of Heroku's database addons does not mean using dynos. These services run as hosted services on the cloud, not on your dynos. JawsDB and ClearDB are both options and both have free tiers.)
If you're talking about something running inside a firewall, e.g. on your laptop, then this won't be possible without doing a bunch of network stuff. It's possible but I strongly urge you not to do this. It's easy to create security issues.

django in product , what are the mandatory services?

I am new to django/apache environment. I am preparing the list of services that are mandatory to get django application running without fail.
I could able to get only two of them in my mind.
1) mysqld -> mysql Daemon.
2) apache2 -> apache daemon.
Could you kindly suggest if any other services required, otherwise the django application fails to run?
you need apache2 mod-wgsi to be installed too:
$ sudo apt-get install libapache2-mod-wsgi
and you have to enable apache2 services:
$ sudo a2enmod mod-wsgi
and disable the default site too
and pass to the apache2 configuration and other
django is a framework; a set of tools that allow you to create web applications - any kind of web application.
There are no list of services required; but if you are asking from a systems management point of view; what is needed to support a typical Python web application:
You need a WSGI compatible runtime. This can be mod_wsgi if you are using Apache; gunicorn or uwsgi.
You may need a process manager if you aren't using mod_wsgi (whose processes are controlled by Apache).
You'll need a web server capable of hosting the static assets for the application. This can be Apache, nginx, lighttpd or any other capable web server.
Most applications will also have some sort of database. What database this is, will depend on the application and its requirements (not all features of the django ORM are supported by all databases). So you'll have to check with each individual application. You may choose to provide a "standard" layout; for example MySQL version xx.yy. It could also be that the application is using an external hosted server; in which case your job is just to provide connectivity to the remote hosts.
If you can take care of the above 4, you have a standard layout for host most Python WSGI-based web applications.
Keep in mind that although Python 3 has been widely available; most libraries are still in the process of being ported so making sure your server provides both Python 2.7 and Python 3 runtimes is important.
You should also make sure that the development headers for Python (and the database server you are supporting) are available - this is important if the Python application runs in a virtual environment (as this is best practice) since the drivers will need to be compiled for each virtual environment. The same also applies for any compiled libraries (like PIL).
Django has a nice deployment section in the documentation to help with specifics.

Mysql: How to configure mysql proxy for an existing master-slave setup

I want to configure mysql proxy on my test environment to observe the below.
1. Behavior of the proxy
2. How load, CPU usage varies on my test server for read/write distribution.
I googled and able to install proxy on my ubuntu linux.
But I didnt see any thing on configuring it in a step by step manner and how to start or stop this.
Shall some one explore on this and this would be of great help for me.
Thanks in advance
Regards,
UDAY
By default if you run the proxy on the same machine as the server it will listen to port 4040 and query a backend server on the msyql default port of 3036. Other port numbers and server locations can be configured from the command line or with a configuration file.
To distribute queries across servers, add monitoring, profiling etc. you need to provide a Lua script to mysql-proxy. See the example / tutorial scripts in /usr/local/share/docs that came with the installation download. There is work to do for a production implementation.
The basics of how the scripting works can be found here under MySQL Proxy Scripting.
Don't be worried about Lua. The syntax is quite readable given the tutorial examples to work from. As and when you need it lua.org has more details of Lua.

Access MySQL via HTTP

Is there any working solution for MySQL to be able to request data directly via HTTP/jsonp way?
I need to provide ready SQL statement to the server.
Something with SQL-templates etc.
There is beta version of mysql 5.7 that does that
MySql experimental MySQL HTTP API
I am currently trying the following alternatives:
YOG-Sql Tunnel in PHP and
Others: (1) undergo writing some webservices (java - php - c), (2) use 'mysql proxy' or 'mysql tunnel' (3) Code everyhing in gcc and run a proxy as http.
Tried many, stayed with YogSQL Tunnel (lot easier) - BTW ALL THOSE DID NOT GAVE SAME REAL-TIME RESULTS AS EVERYTHING INSIDE THE SAME DATACENTER (2 servers) or a gigabit network (250k - 500k records/second). So, latency may be a killer on one's ubiquitous cloud computing.
No, there is no way to do this.
I tried NGINX http add-on modules
ngnix really rocks, on static html even amazon free was outstanding (1ms wait) on 3000 requests/sec. Specific SQL modules, whatsoever, may be memory-consumig if goes heavy loader.io.

What is the difference between using Glassfish Server -> Local and Remote

I am using Intellij IDEA to develop my applications and I use glassfish for my applications.
When I want to run/debug my application I can configure it from Glassfish Server -> Local and define arguments at there. However there is another section instead of Glassfish Server, there is a Remote section for configuration. I can easily configure and debug my application just defining host and port variables.
So my question is why to need for Glassfish Server Local configuration(except for when defining extra parameters) and what is difference between them(I mean performance or etc.)?
There are a number of development work-flow optimizations and automation that can be performed by an IDE when it is working with a local server. I don't have a strong background in IDEA, so I am not sure which of the following they may have implemented:
using in-place|exploded|directory deployment can eliminate jar/war/ear creation in the IDE and deconstruction in the server. This can be a significant time saver.
linked to 1 is smarter redeployment. In some cases, a file change (like changing a jsp or an html file) does not need to trigger redeployment.
JDBC driver integration allows users to configure their IDE to access a DB and then propagates that configuration (which usually includes driver jars, etc.) into the server's classpath as part of deployment of an app.
access to server log files during deployment and execution.
The ability to start and stop the server... even today, you do need to restart GlassFish sometimes.
view the generated Java sources of a JSP.
Most of these features are not available with a remote server and that has a negative effect on iterative development since the break between edit and validate can be fairly long.
This answer is based on my familiarity with the work that we have done for the NetBeans/GlassFish integration. The guys at IntelliJ are smart, so I would not be surprised if they have other features that are available when you are working with a local server.
Local starts Glassfish for you and performs the deployment. With Remote you start Glassfish manually. Remote can be used to debug apps running on another machines, Local is useful for development and testing.