python, web 以及 后台开发

来源:互联网 发布:一搜影咖软件 编辑:程序博客网 时间:2024/05/09 16:20

系统架构相关

Nginx

Nginx开发从入门到精通
nginx 启动失败原因:端口占用,配置文件语法错误…

HAProxy

负载均衡基础
http://www.haproxy.com/resources/faq-technical-articles/
其中 The application scalability with load balancing 非常值得一读,可以当作负载均衡知识的零基础教程

Redis

Redis In Action

RabbitMQ

RabbitMQ In Action

Docker

官方安装教程 for os x
官方doc
Docker 入门实战 (中文书)

Docker 从入门到实践

一个供参考的 docker 开发-部署 方案,文章本身比较旧了

阿里云安装 docker

apt-get install docker.io docker

docker-flask 镜像

https://hub.docker.com/r/p0bailey/docker-flask/

etcd

etcd:从应用场景到实现原理的全方位解读
http://www.infoq.com/cn/articles/coreos-analyse-etcd/
official doc

Web 应用框架

Flask

目前读的是 Flask Web Development。
wtforms 文档

异步

Twisted

啄木鸟 twisted
twistedmatrix.com
http://jessenoller.com/2009/02/11/twisted-hello-asynchronous-programming/

生产环境工具

supervisor

http://www.ttlsa.com/linux/using-supervisor-control-program/

配置 celery + virtualenv + supervisor

celery在github上有supervisor的配置示例
https://github.com/celery/celery/tree/master/extra/supervisord

文档, 协议, 标准

wsgi

pep 3333
read the docs

uWsgi

quick start
http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html
简明现代魔法上面的系列文章
http://www.nowamagic.net/academy/detail/1330308

我的理解:
uWsgi 是实现了 wsgi 和 uwsgi 两种协议的web服务器。
它完全可以独立地来提供服务。

下面的命令让 uWsgi 运行在 120.131.12.121:9090 上
–http 参数让 uWsgi 在该地址上运行 http 协议(默认是 uwsgi)
通过浏览器访问 120.131.12.121:9090,就可以看到 Hello World 了。

uwsgi --http 120.131.12.121:9090 --wsgi-file foobar.py --master --processes 4 --threads 2

foobar.py 看起来是这样的,一个简单的 wsgi 接口

def application(env, start_response):    start_response('200 OK', [('Content-Type','text/html')])    return [b"Hello World"]

通常把 uWsgi 放在更专业的 web server 的后端,以提高性能。
如 uWsgi + nginix 的组合。
阿里云上配置 flask http://www.tuicool.com/articles/zUvqMr

数据库

MongoDB

阅读:mongodb 权威指南, docs.mongodb.org
索引
索引最基本的 prefix 原则
索引性能调试

API 文档

Pymongo
https://docs.mongodb.org/getting-started/python/
http://api.mongodb.org/python/current/api/pymongo/index.html

性能查看
mongostat, mongotop

mysql

mysql 没有 upsert 这一语法 ,不过有类似实现,虽然操作比起 mongo 等稍复杂,但弹性更高。

日志

python logging 模块提供了很强大的日志功能
同时文档也很完善
https://docs.python.org/2/howto/logging-cookbook.html#logging-cookbook
给一个配置样例

测试

Python 单元测试模块
https://segmentfault.com/a/1190000000400091

工作环境

vim 配置

Ubuntu下个人配置(只对当前用户生效)

cp /etc/vim/vimrc ~/.vimrc    # vim 会自动读取该配置文件set expandtab   # 把tab转换成空格set shiftwidth=4  # When auto-indenting, indent by this much.set softtabstop=4    # Make Vim treat <Tab> key as 4 spaces, but respect hard Tabs.

对 .vimrc 的配置

set nu  # 显示行号

开发协作

Git

pro git

Mercurial

其他

爬虫相关

scrapy 分布式爬虫,scrapy-redis

app 抓包,charles, android 模拟器(Droid4x)

反爬虫策略
http://zhangge.net/4458.html

0 0
原创粉丝点击