Giter Club home page Giter Club logo

paper's People

Contributors

liwh avatar

Watchers

 avatar  avatar

paper's Issues

分析redis内存占用

Redis分析

由于最近使用redis作为我们后端的一持久化方案的选择,所以,也遇到了一些问题。一些key在项目中的使用不当,导致某个key或者某些key占用的内存相对过大。这一个还是要相对避免的。

那么,如何分析redis产生的持久化文件,找出各个key占用的内存大小了。最开始,是打算自己写段脚本自己分析下。后来,翻开了Github,找到了个哥么,已经写好了这一块东西,那么就直接拿来用吧,项目地址rdb-tools. 这个工具能帮助我们分析各个�key占用的内存大小,以及数据结构等等。使用起来也挺方便的。

使用方法如下

rdb -c memory xx/xx/dump.rdb > memory.csv

这个就会将rdb所有的key按如下格式输出所有key的内容

database,type,key,size_in_bytes,encoding,num_elements,len_largest_element

然后,我们需要对所有的key按大小排列,我们可以使用如下命令

cat memory.csv |sort -n -r -t ',' -k 4 > memory_sort_reverse.csv

这样,我们就能将其按内存占用大小排列了。

大体内容如下:

database,type,key,size_in_bytes,encoding,num_elements,len_largest_element
0,list,"v1:#v:snapshots:invalid",3054162788,linkedlist,20514323,92
0,hash,"v1:#v:snapshots:performing",2657536239,hashtable,1562991,13537
0,list,"v1:#v:snapshots:failed",1265261420,linkedlist,117594,13502
0,list,"v1:#v:snapshots:dispatched",59462267,linkedlist,60713,925
0,list,"v1:#v:snapshots:dispatching",55165391,linkedlist,60713,854
0,list,"v1:#u:queue:waiting_add",27874976,linkedlist,582034,11
0,hash,"v1:#v:performing",11828111,hashtable,10287,4925

Nginx超时设置

今天,帮同事查看了一个问题。就是请求第三方苹果支付接口时间超长,导致整个接口直接504.同事以为是代码处理的问题。经查看,其实,就是请求的时间大于了Nginx默认的timeout时间,自然导致了接口的504

处理这种强依赖关系的接口,可以将Nginx对单个接口的超时时间设长一点。对其做相应的处理会较好。

    # proxy time
    proxy_connect_timeout 3;
    proxy_send_timeout 3;
    proxy_read_timeout 3;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.