to see the difference between free and real_free (free + cached) i
check i output from top vs htop
maybe this helps:
http://www.linuxatemyram.com/
cheers,
mex
2016-06-04 8:46 GMT+02:00 Nithin Mohan <nithin...@gmail.com>:
> Hi,
> I deployed my openresty server yesterday with around 1 GB free memory.Now it
> is only 100MB and decreasing. I deployed my development code directly
> serving some traffic through it. So I think I may have missed some
> production configurations. Initially I suspected redis, but it uses only
> 20MB memory. I didn't use any global variables anywhere. But many lua tables
> are used. Also lua code cache is turned on. I am fine with it is leaves
> memory alone.Server is up and people are using it. Please help guys .
>
> EDIT: Is this because of cache?
> This is the output of free -m
>
> total used free shared buffers cached
> Mem: 2001 1887 113 0 188 1489
> -/+ buffers/cache: 210 1791
> Swap: 0 0 0
>
>
>
>
> And this is ps aux output
>
> root 360 0.0 0.0 43868 1644 ? Ss May31 0:00
> /lib/systemd/systemd-udevd --daemon
> root 473 0.0 0.0 0 0 ? S< May31 0:00 [ttm_swap]
> root 537 0.0 0.0 0 0 ? S< May31 0:00
> [kvm-irqfd-clean]
> message+ 787 0.0 0.0 39224 1252 ? Ss May31 0:00 dbus-daemon
> --system --fork
> root 818 0.0 0.0 43448 1800 ? Ss May31 0:00
> /lib/systemd/systemd-logind
> syslog 821 0.0 0.9 256228 18944 ? Ssl May31 0:16 rsyslogd
> root 902 0.0 0.0 15816 956 tty4 Ss+ May31 0:00 /sbin/getty
> -8 38400 tty4
> root 905 0.0 0.0 15816 964 tty5 Ss+ May31 0:00 /sbin/getty
> -8 38400 tty5
> root 910 0.0 0.0 15816 960 tty2 Ss+ May31 0:00 /sbin/getty
> -8 38400 tty2
> root 911 0.0 0.0 15816 960 tty3 Ss+ May31 0:00 /sbin/getty
> -8 38400 tty3
> root 913 0.0 0.0 15816 960 tty6 Ss+ May31 0:00 /sbin/getty
> -8 38400 tty6
> root 931 0.0 0.1 61376 3064 ? Ss May31 0:15
> /usr/sbin/sshd -D
> root 936 0.0 0.0 23652 940 ? Ss May31 0:00 cron
> daemon 937 0.0 0.0 19136 160 ? Ss May31 0:00 atd
> root 982 0.0 0.0 4364 664 ? Ss May31 0:00 acpid -c
> /etc/acpi/events -s /var/run/acpid.socket
>
>
> root 1026 0.0 0.0 15816 960 tty1 Ss+ May31 0:00 /sbin/getty
> -8 38400 tty1
> root 1104 0.0 0.0 0 0 ? S< May31 0:00
> [kworker/u5:2]
> root 1144 0.0 0.0 0 0 ? S May31 0:00 [kauditd]
> root 1843 0.0 0.0 19472 388 ? S May31 0:00
> upstart-udev-bridge --daemon
> root 1846 0.0 0.0 15272 404 ? S May31 0:00
> upstart-file-bridge --daemon
> root 1849 0.0 0.0 15256 412 ? S May31 0:00
> upstart-socket-bridge --daemon
> root 11258 0.0 0.0 0 0 ? S Jun03 0:00
> [kworker/u4:0]
> root 16631 0.0 0.2 105640 4304 ? Ss 01:38 0:00 sshd: track
> [priv]
> track 16705 0.0 0.0 105772 1956 ? S 01:39 0:01 sshd:
> track@pts/0
> track 16707 0.0 0.1 22436 3756 pts/0 Ss+ 01:39 0:00 -bash
> root 16986 0.0 0.2 105640 4308 ? Ss 01:47 0:00 sshd: track
> [priv]
> track 17047 0.0 0.0 105640 1976 ? S 01:47 0:00 sshd:
> track@pts/2
> track 17048 0.0 0.1 22392 3568 pts/2 Ss+ 01:47 0:00 -bash
> root 17706 0.0 0.0 0 0 ? S May31 0:00
> [kworker/1:2]
> root 18983 0.0 0.2 105640 4308 ? Ss 01:54 0:00 sshd: track
> [priv]
> track 19033 0.0 0.0 105640 1976 ? S 01:54 0:00 sshd:
> track@pts/3
> track 19034 0.0 0.1 22444 3764 pts/3 Ss 01:54 0:00 -bash
> root 19655 0.0 0.1 104424 3756 ? Ss 02:11 0:00 sshd: root
> [priv]
> sshd 19657 0.0 0.0 62792 1524 ? S 02:11 0:00 sshd: root
> [net]
> track 19699 0.0 0.0 18440 1288 pts/3 R+ 02:12 0:00 ps aux
> root 24627 0.0 0.1 65180 2316 pts/1 S Jun03 0:00 sudo
> /usr/local/openresty/nginx/sbin/nginx -c /home/track/url_track/proj.conf -p
> /home/track/url_
> root 24628 0.0 0.1 41636 3560 pts/1 S Jun03 0:00 nginx:
> master process /usr/local/openresty/nginx/sbin/nginx -c
> /home/track/url_track/proj.conf -p
> nobody 24629 0.1 0.1 41636 2580 pts/1 S Jun03 1:40 nginx:
> worker process
> root 25576 0.1 1.3 54816 28400 ? Ssl May31 9:14
> /usr/local/bin/redis-server 127.0.0.1:6379
> track 31307 0.0 0.0 27196 1496 ? Ss Jun01 0:00 SCREEN
> track 31308 0.0 0.1 22416 3764 pts/1 Ss+ Jun01 0:00 /bin/bash
> root 31690 0.0 0.0 0 0 ? S Jun01 0:00
> [kworker/0:0]
>
>
>
> ```
> Code of main lua script
>
> local red=require("redis_connect")()
> local url_helper=require("url_helper")
> local db=require("db")
> local logger=require("logger")
>
>
> local full_url=url_helper.get_full_url()
> -- local params_table=url_helper.create_table_from_url(full_url)
> local params_table=ngx.req.get_uri_args()
> if params_table["transaction_id"]== nil then
> ngx.say("no transaction_id")
> return false
> end
> if params_table["off_id"]== nil then
> ngx.say("no off_id")
> return false
> end
> if params_table["aff_id"]== nil then
> ngx.say("no aff_id")
> return false
> end
> local template, err =
> db.get_adv_template(red,params_table["off_id"],params_table["aff_id"])
> if not template then
> ngx.exit(ngx.OK)
> end
> if template == ngx.null then
> logger.log("template not found.")
> return
> end
>
>
> logger.log(full_url);
> local redirect_link=url_helper.replace_url_from_table(template,params_table)
> logger.log(redirect_link);
>
>
>
>
> local ok,err=db.save_transaction(red,full_url,params_table)
>
>
> if not ok then
> logger.log("failed save: ", err)
> return
> end
> logger.log("CLICK:","TR_ID:"..params_table["transaction_id"]..",OFF_ID:"..params_table["off_id"]..",AFF_ID:"..params_table["aff_id"])
>
>
> -- put it into the connection pool of size 100,
> -- with 10 seconds max idle time
> local ok, err = red:set_keepalive(10000, 100)
> if not ok then
> logger.log("failed to set keepalive: ", err)
> return
> end
>
>
>
>
> local request_time = ngx.now() - ngx.req.start_time()
> ngx.log("01",request_time)
> return return ngx.redirect(redirect_link).