checgg 最近的时间轴更新
checgg

checgg

V2EX 第 115469 号会员,加入于 2015-05-06 13:47:13 +08:00
当我们在谈论高并发的时候究竟在谈什么?
  •  2   
    程序员  •  checgg  •  2019-06-03 10:26:00 AM  •  最后回复来自 checgg
    26
    请教一下各个抢票网站是怎么支付 12306 的订单的呢?
    问与答  •  checgg  •  2019-05-09 19:39:46 PM  •  最后回复来自 c4f36e5766583218
    2
    数据表在各个业务之间同步有什么其它高效的实现方案吗?
    问与答  •  checgg  •  2018-12-20 12:42:12 PM  •  最后回复来自 julyclyde
    3
    问一下大家是怎么理解 replica set 和 master-slave 的?
    程序员  •  checgg  •  2018-09-29 13:48:08 PM  •  最后回复来自 mogami95
    1
    请问某些字符撑大 table 的 td 怎么处理?
    问与答  •  checgg  •  2018-08-29 09:48:10 AM  •  最后回复来自 checgg
    15
    为什么 ES6 的实例类不能调用静态方法?
    问与答  •  checgg  •  2018-06-21 09:40:39 AM  •  最后回复来自 AlloVince
    11
    如何理解 “架构独立于业务又服务于业务”?
    程序员  •  checgg  •  2018-05-29 08:53:40 AM  •  最后回复来自 gevin
    8
    请教 Python 如何调用 arm 编译的 so 文件?
    问与答  •  checgg  •  2018-05-14 08:53:38 AM  •  最后回复来自 izoabr
    8
    charles 抓包显示的这个东西叫什么?
    问与答  •  checgg  •  2018-04-24 10:24:01 AM  •  最后回复来自 explore365
    9
    checgg 最近回复了
    2019-06-03 10:26:00 +08:00
    回复了 checgg 创建的主题 程序员 当我们在谈论高并发的时候究竟在谈什么?
    @Aruforce @zhuyichen1017

    https://github.com/netty/netty/tree/4.1/example/src/main/java/io/netty/example/http/helloworld

    65-69 行:

    ```
    /*
    * Copyright 2013 The Netty Project
    *
    * The Netty Project licenses this file to you under the Apache License,
    * version 2.0 (the "License"); you may not use this file except in compliance
    * with the License. You may obtain a copy of the License at:
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    * License for the specific language governing permissions and limitations
    * under the License.
    */
    package io.netty.example.http.helloworld;

    import io.netty.buffer.Unpooled;
    import io.netty.channel.ChannelFuture;
    import io.netty.channel.ChannelFutureListener;
    import io.netty.channel.ChannelHandlerContext;
    import io.netty.channel.SimpleChannelInboundHandler;
    import io.netty.handler.codec.http.DefaultFullHttpResponse;
    import io.netty.handler.codec.http.FullHttpResponse;
    import io.netty.handler.codec.http.HttpObject;
    import io.netty.handler.codec.http.HttpRequest;
    import io.netty.handler.codec.http.HttpUtil;

    import static io.netty.handler.codec.http.HttpHeaderNames.CONNECTION;
    import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_LENGTH;
    import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_TYPE;
    import static io.netty.handler.codec.http.HttpHeaderValues.CLOSE;
    import static io.netty.handler.codec.http.HttpHeaderValues.KEEP_ALIVE;
    import static io.netty.handler.codec.http.HttpHeaderValues.TEXT_PLAIN;
    import static io.netty.handler.codec.http.HttpResponseStatus.OK;

    public class HttpHelloWorldServerHandler extends SimpleChannelInboundHandler<HttpObject> {
    private static final byte[] CONTENT = { 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd' };

    @Override
    public void channelReadComplete(ChannelHandlerContext ctx) {
    ctx.flush();
    }

    @Override
    public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) {
    if (msg instanceof HttpRequest) {
    HttpRequest req = (HttpRequest) msg;

    boolean keepAlive = HttpUtil.isKeepAlive(req);
    FullHttpResponse response = new DefaultFullHttpResponse(req.protocolVersion(), OK,
    Unpooled.wrappedBuffer(CONTENT));
    response.headers()
    .set(CONTENT_TYPE, TEXT_PLAIN)
    .setInt(CONTENT_LENGTH, response.content().readableBytes());

    if (keepAlive) {
    if (!req.protocolVersion().isKeepAliveDefault()) {
    response.headers().set(CONNECTION, KEEP_ALIVE);
    }
    } else {
    // Tell the client we're going to close the connection.
    response.headers().set(CONNECTION, CLOSE);
    }
    try {
    Thread.sleep(10);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    ChannelFuture f = ctx.write(response);

    if (!keepAlive) {
    f.addListener(ChannelFutureListener.CLOSE);
    }
    }
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    cause.printStackTrace();
    ctx.close();
    }
    }

    ```
    2019-06-01 20:57:04 +08:00
    回复了 checgg 创建的主题 程序员 当我们在谈论高并发的时候究竟在谈什么?
    一位常年潜水的个人开发者,没有任何广告哈~~
    写了一些本人的一点沉淀和思考。
    2018-11-25 13:06:28 +08:00
    回复了 wleexi 创建的主题 程序员 服务端防止重复提交
    这个问题的实际需求是什么?
    1 防止提交两次?
    这只能客户端去解决。

    2 防止数据入库两次?
    那么重复提交的定义是什么?
    两个客户端,提交同一份数据,算重复提交吗?
    如果算,设置数据库唯一索引就好,写入相同数据会失败。
    如果不算,服务端没法验证。因为客户端请求都可以伪造。
    这是啥问题?
    并行和并发的定义是啥,不理解,能否补充一下英文关键词或者具体业务场景?
    大量 IO 是指的磁盘 IO 还是网络 IO ?
    @oldbai
    哈哈哈哈
    2018-08-29 09:48:10 +08:00
    回复了 checgg 创建的主题 问与答 请问某些字符撑大 table 的 td 怎么处理?
    @azh7138m 👍
    2018-08-28 17:00:03 +08:00
    回复了 checgg 创建的主题 问与答 请问某些字符撑大 table 的 td 怎么处理?
    @gzf6
    @Sparetire
    fixed '。。。。' 会到表格外面去。
    2018-08-28 10:54:23 +08:00
    回复了 checgg 创建的主题 问与答 请问某些字符撑大 table 的 td 怎么处理?
    @TomatoYuyuko 不能 hidden。
    如果业务需要这个东西打印出来呢。。。。
    2018-08-22 09:28:09 +08:00
    回复了 PHPer233 创建的主题 PHP 如何实现在 Web 页面中点一下按钮就能启动一个 PHP 进程?
    简单点的丢数据库跑 cron。
    优雅点的丢 MQ 或者 swoole 常驻内存实现。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4638 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 04:00 · PVG 12:00 · LAX 20:00 · JFK 23:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.