A small functional person-to-person message center application built using Django. It has a REST API and uses WebSockets to notify clients of new messages and avoid polling.
"Because Channels takes Django into a multi-process model, you no longer run everything in one process along with a WSGI server (of course, you’re still free to do that if you don’t want to use Channels). Instead, you run one or more interface servers, and one or more worker servers, connected by that channel layer you configured earlier."
In this case, I'm using the In-Memory channel system, but could be changed to the Redis backend to improve performance and spawn multiple workers in a distributed environment.
Please take a look at the link below for more information: https://channels.readthedocs.io/en/latest/introduction.html
update 04/06/19
For this demo, I'm using a simple MySQL setup. If more performance is required, a MySQL cluster / shard could be deployed.
PD: I'm using indexes to improve performance.
Because of time constraints this project lacks of:
move to project root folder
Create and activate a virtualenv (Python 3)
pipenv --python 3 shell
pipenv install
CREATE DATABASE chat CHARACTER SET utf8;
redis-server
./manage.py migrate
./manage.py test
./manage.py createsuperuser
./manage.py runserver
To override default settings, create a local_settings.py file in the chat folder.
Message prefetch config (load last n messages):
MESSAGES_TO_LOAD = 15
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。