以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  CPU消耗  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=152861)

--  作者:刘林
--  发布时间:2020/7/23 21:17:00
--  CPU消耗
双核4G服务器手机用户一多就cup跑到100%,整个系统卡死白屏,请问老师,如何在设计上从哪些方减少CPU消耗
--  作者:有点蓝
--  发布时间:2020/7/23 21:41:00
--  
是foxtable占用的cpu?还是数据库?

nginx设置为多核模式
--  作者:刘林
--  发布时间:2020/7/24 11:07:00
--  
现在服务器我升成了4核8G内存,12M带宽,还是容易跑到100%,并且在线人也应该不多,手机进不到,白屏,怎么办哟

1.请问nginx设置为多核模式怎么设置
2.该改进的都改了些了,还是不行,有不有fox本身的局限因素。
[此贴子已经被作者于2020/7/24 11:27:38编辑过]

--  作者:有点蓝
--  发布时间:2020/7/24 11:29:00
--  
那就是代码有问题了,有比较费时的操作,或者不停的循环操作,比如动不动就加载整个表的数据,甚至是在循环代码里不停加载整个表的操作
--  作者:有点蓝
--  发布时间:2020/7/24 11:30:00
--  
以下是引用刘林在2020/7/24 11:07:00的发言:
现在服务器我升成了4核8G内存,12M带宽,还是容易跑到100%,并且在线人也应该不多,手机进不到,白屏,怎么办哟

请问nginx设置为多核模式怎么设置

好像是这个吧 worker_processes 4;
--  作者:刘林
--  发布时间:2020/7/24 11:50:00
--  
worker_processes  4;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  10000;
upstream  njsjwxt.com{
    server 47.92.95.136:8083;
    server 47.92.95.136:8081;
    server 47.92.95.136:8082;
    server 47.92.95.136:8084;
 
}
    server {
        listen   8888;
        server_name  localhost;
        location / {
            proxy_pass http://njsjwxt.com;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

这样吗?

--  作者:有点蓝
--  发布时间:2020/7/24 12:19:00
--  
第三方的东西学会百度:https://www.baidu.com/baidu?word=worker_processes
--  作者:刘林
--  发布时间:2020/7/24 19:02:00
--  
worker_processes  4;
events {
    worker_connections  2048;
}

还是很卡,不读数据库,显示图片文字都很慢,老师,还有什么招可用?

--  作者:有点蓝
--  发布时间:2020/7/25 9:19:00
--  
重构您的项目,新建一个项目,把其中一个功能搬到新项目,重新理清所有代码逻辑。

不要动不动就查询返回整个表的数据

--  作者:刘林
--  发布时间:2020/7/27 8:17:00
--  
老师:
我测试发现:
1、不用hbulider打包的APP,而是在手机网页浏览器中打开网址,同等条件下明显反应更快,现在已升为4核8G,用了nginx明显比不用nginx慢很多
2、对不打开数据的网页仍是感觉慢。
3、请老师帮看一下下面这个代码如何优化才能更高效,我好改进其他类似代码
\'\'\'
Dim e As RequestEventArgs = args(0)
Dim path As String = "foxtableAppTest"
Dim wb As new weui
wb.appendHTML("<meta name=\'viewport\' c />",True)
wb.AppendHTML("<script type=\'text/javascript\' src=\'/" & path & "/js/common.js\'></script>", True)
wb.AppendHTML("<link rel=\'stylesheet\' href=\'/" & path & "/css/common.css\' Type=\'text/css\' charset=\'utf-8\'/>", True)
wb.appendHTML("<script src=\'../mui/css/mui.css\'></script>",True)
wb.appendHTML("<script src=\'../mui/js/mui.js\'></script>",True)
wb.appendHTML("<script Type=\'text/javascript\' charset=\'utf-8\'>mui.init();</script>",True)
wb.appendHTML("<style>.fox_page_title{color:white}</style>",True)
wb.appendHTML("<style>.fox_page_subtitle{color:white;}</style>",True)
wb.appendHTML("<style>.fox_page_header{background-color:dodgerblue;}</style>",True)
wb.appendHTML("<style>.weui_label{color:dodgerblue;}</style>",True)
wb.appendHTML("<style>h5,p{margin:8px 16px;}</style>",True)
Dim cmd1 As new SQLCommand
cmd1.C
cmd1.CommandText ="Se/ect DISTINCT 单位,部门,角色 from {单位用户} where 角色=\'班务\'"
Dim dt1 As DataTable =  cmd1.ExecuteReader
Dim xxs As List(of String)=dt1.GetValues("单位")
wb.AddPageTitle("","ph1","学生报名","请扫描学校给定的报名码或选填学校及班级")
wb.AddForm("","form1","bmxx.htm")
With wb.AddInputGroup("form1","ipg1","")    \'
    Dim In1 = .AddInput("身份证号","身份证号:","Text")
    In1.readonly = True
    In1.value = e.Cookies("username")
    Dim In2= .AddInput("学生姓名","学生姓名:","Text")
    In2.readonly = True
    In2.value = e.Cookies("userxm")
    Dim cmd As new SQLCommand
    cmd.C
    cmd.CommandText = "SE/ECT 身份证件号,申读学校,申读班级,录取类型,问题 FROM {学生信息} where 身份证件号 =\'" & e.Cookies("username") & "\'"
    Dim dt As DataTable = cmd.ExecuteReader()
    Dim dr As DataRow
    If dt.DataRows.Count>0
        dr = dt.DataRows(0)
        If dr("录取类型")>""
            Dim Int1= .AddSelect("申读学校","申读学校:",dr("申读学校"))
            \'  int1.enabled=False
            Dim Int2= .Addselect("申读班级","申读班级:",dr("申读班级"))
            \'int2.enabled=False
        Else
            Dim Int1 =.AddSelect("申读学校","申读学校:"," |" & String.join("|",xxs.Toarray).replace(e.Cookies("sdxx"), "[" & e.Cookies("sdxx") & "]"))
            Int1.attribute=""
            Dim Int2= .Addselect("申读班级","申读班级:",dt1.GetComboListString("部门","单位=\'" & e.Cookies("sdxx") & "\'").replace(e.Cookies("sdbj"), "[" & e.Cookies("sdbj") & "]"))
            
        End If
    Else
        If e.Cookies.ContainsKey("sdxx")
            Dim Int1 =.AddSelect("申读学校","申读学校:"," |" & String.join("|",xxs.Toarray).replace(e.Cookies("sdxx"), "[" & e.Cookies("sdxx") & "]"))
            Int1.attribute=""            
        Else
            Dim Int1 =.AddSelect("申读学校","申读学校:"," |" & String.join("|",xxs.Toarray))
            Int1.attribute=""            
        End If        
        If e.Cookies.ContainsKey("sdbj")
            Dim Int2= .Addselect("申读班级","申读班级:",dt1.GetComboListString("部门","单位=\'" & e.Cookies("sdxx") & "\'").replace(e.Cookies("sdbj"), "[" & e.Cookies("sdbj") & "]"))
        Else
            Dim Int2= .Addselect("申读班级","申读班级:","")
        End If
    End If
    .AddHiddenValue("类型","a")
    With wb.AddButtonGroup("form1","btg1",False)
        Dim btn1= .Add("btn1", "扫报名码", "button")
        If dr IsNot Nothing AndAlso dr("录取类型")>""
            btn1.kind=1
            btn1.enabled=False
        Else
            btn1.Attribute = " & path & "/plus/barcode_scan.html\',true,true);"""
            btn1.kind=1
        End If
        Dim btn2= .Add("btn2", "信息填报", "submit")
        btn2.kind=1
        Dim btn3= .Add("btn3", "返回", "button")
        btn3.kind=1
        btn3.Attribute=""
    End With
    If dr IsNot Nothing AndAlso dr("问题")>""
        wb.InSertHtml("form1","<p style= \'font-size:15px;color:red;\'>存在信息问题,请修改提交:</P>")
        wb.InSertHtml("form1","<p style= \'font-size:15px;\'>" & dr("问题") & "</P>")
    End If
    If dr IsNot Nothing AndAlso dr("录取类型")>""
        wb.InSertHtml("form1","<div style= \'background:url(../picture/nqbj.jpg);height:150px;background-size:cover\'>" )
        wb.InSertHtml("form1","<p style= \'text-align:center;font-size:20px;color:white;margin-top:20px;\'>录取通知</P>")
        wb.InSertHtml("form1","<p style = \'text-indent:2em;color:white;\'>经学校招生小组审核同意,你已被我校录取,请按相关时间安排入学就读,如有申读学校变更,需经学校教务处同意方可进行变更。</P>")
        wb.InSertHtml("form1","</div>")
    End If
End With
wb.InsertHTML("<script>function scaned( t, r, f ) {document.getElementById(\'申读学校\').value=r.split(\',\')[0]; document.getElementById(\'申读班级\').value=r.split(\',\')[1];document.getElementById(\'类型\').value=r.split(\',\')[2]}</script>")
For Each xx As String In xxs
    wb.InsertHTML("<p hidden id=\'" & xx & "\'>" & " |" & dt1.GetComboListString("部门","单位=\'" & xx & "\'") & "</p>")
Next
wb.AppendHTML("<script src=./lib/getsdbj.js></script>")
e.WriteString(wb.Build)
e.Handled=True