今天早上來公司發(fā)現(xiàn) mysql 被刪了...只留下了比特幣地址和郵箱.搜地址和數(shù)據(jù)庫關(guān)鍵詞發(fā)現(xiàn)這幾天有好多人中招....現(xiàn)在恢復(fù)了表....做了自動(dòng)快照,寶塔后臺(tái)也開通了網(wǎng)站防火墻,修改了數(shù)據(jù)庫密碼,限制了指定 ip 登錄.....不知道有沒有用,有大佬有類似的經(jīng)驗(yàn)么,這種會(huì)不會(huì)來第二次
公司目前希望能固定化下來 CI/CD 流程. 這樣方便公司統(tǒng)一去管理. 固定的流程會(huì)減少開發(fā)的理解成本. 但也帶來了一些問題.一些需要自由度比較高的項(xiàng)目, 或者一些小小的改動(dòng)都有可能沖擊之前的固化流程. 如果是做平臺(tái), 個(gè)人感覺反而開發(fā)可以定制化構(gòu)建步驟更好一些. 平臺(tái)方只需要給開發(fā)一系列的步驟來滿足構(gòu)建部署需求.
接口日志是記錄在哪里? 日志文件嗎? 是否將接口請(qǐng)求的 request header 和傳入的參數(shù),服務(wù)端輸出的 response header 和數(shù)據(jù)都記錄到日志里? 業(yè)務(wù)中日志記錄是否有規(guī)范,比如要求按某種格式寫:“{觸發(fā)記錄日志的文件名和行數(shù)} {原因} {其他涉及的參數(shù)}”
我在的公司記錄的是日志文件,查看日志只能才 FTP 上下載日志文件下來看,有時(shí)候日志文件幾十 M,下載的時(shí)候還會(huì)拖到服務(wù)器的帶寬,感覺這個(gè)做法不好
https://jiajunhuang.com/articles/2020_02_19-should_i_use_microservice.md.html
微服務(wù),火了好幾年的東西。曾經(jīng)我們看中的是微服務(wù)拆分之后,每個(gè)項(xiàng)目變得更小,對(duì)團(tuán)隊(duì)的每個(gè)人來說維護(hù)成本降低,因?yàn)樾枰私?的東西局限于一個(gè)更小的服務(wù)。第二是加強(qiáng)了技術(shù)選型的靈活性。但是由于沒有實(shí)踐,并不知道微服務(wù)會(huì)帶來什么大的問題。 當(dāng)我們大規(guī)模應(yīng)用微服務(wù)之后,問題才開始慢慢顯現(xiàn)出來。 網(wǎng)絡(luò)調(diào)用過多 技術(shù)棧太過靈活 難于應(yīng)對(duì)連表查詢的需求 核心應(yīng)用崩潰會(huì)導(dǎo)致大面積癱瘓 運(yùn)維成本增加 接口風(fēng)格不一致
上面就是個(gè)人總結(jié)的一些微服務(wù)所帶來的問題。對(duì)每個(gè)缺點(diǎn)的詳細(xì)說明請(qǐng)看原文 :)
現(xiàn)在用兩臺(tái)配置了 LVS(DR)模式做端口轉(zhuǎn)發(fā)+高可用,后端是兩臺(tái) apache http server 做正向代理。最近有個(gè)奇怪得問題,apache 代理的某個(gè) URL 變慢了,導(dǎo)致了 Client 端訪問 LVS 提供的虛 IP+端口出現(xiàn)了大量的 Connection Timeout 和 Connection Refused 錯(cuò)誤,我用 telnet 測試是瞬間 Connection Refused。把 LVS APACHE 和這四臺(tái)機(jī)器的內(nèi)核參數(shù)查了一遍,好像也沒什么問題。大佬能提供一個(gè)排查的思路嗎?
Python 寫了一些 Devops (運(yùn)維)相關(guān)的系統(tǒng),這些系統(tǒng)都在我們內(nèi)部跑了很久,效果顯著成績斐然,這里給匯總了下,對(duì) Devops 感興趣的小伙伴可以看看,有私有有開源
https://ops-coffee.cn/devops
目前我涉及到做點(diǎn)贊這塊,起初的設(shè)計(jì)是直接落庫,用戶的點(diǎn)贊和取消點(diǎn)贊直接對(duì)記錄進(jìn)行加減,這樣的方案似乎很簡單看起來也沒啥問題,但是一旦流量多了起來,數(shù)據(jù)庫肯定扛不住這么頻繁的讀寫。
我參考了一些網(wǎng)上教程,基本都是采用 redis 異步入庫,就是點(diǎn)贊和取消都交給 redis,redis 記錄了點(diǎn)贊人和被點(diǎn)贊人,同時(shí)在另外記錄點(diǎn)贊總數(shù),然后通過定時(shí)任務(wù)進(jìn)行異步落庫并刪除 redis 中的指定數(shù)據(jù)。
但是現(xiàn)在新的問題來了,當(dāng)我要查詢某個(gè)文章的點(diǎn)贊總數(shù)的時(shí)候,怎么保證數(shù)據(jù)的一致性呢,豈不是查詢的總數(shù)的時(shí)候需要 mysql+redis = 總數(shù)才能保證唯一性,因?yàn)?redis 入庫后記錄就被刪除了,防止內(nèi)存龐大,而且 redis 并不會(huì)做持久化,麻煩做過這方面的大牛給我指點(diǎn)指點(diǎn)
通常的部署方式是 nginx 負(fù)載均衡到多個(gè)端口,每個(gè)端口綁定開啟一個(gè) tornado 服務(wù),通過 supervisor 可以很方便監(jiān)控服務(wù)。 現(xiàn)在想 tornado 多進(jìn)程用 docker 部署,具體的架構(gòu)方案是怎么樣的?是一個(gè) docker 容器一個(gè)進(jìn)程還是一個(gè) docker 多個(gè)進(jìn)程?
看得教程一頭霧水, 只能理解那個(gè)自帶的 http 請(qǐng)求, 看了很久也沒看到有比如數(shù)據(jù)庫查詢, 文件處理什么的其他例子, 后來去看看其他教程, 實(shí)現(xiàn)倒算是勉強(qiáng)實(shí)現(xiàn)了, 但感覺也太復(fù)雜了吧? ?
就比如例子中的我假設(shè)有個(gè)長耗時(shí)的任務(wù), 怎么寫才會(huì)簡單點(diǎn)? import tornado.ioloop import tornado.web import time import _thread # 模擬耗時(shí)任務(wù) def long_work(arg): time.sleep(5) yield arg * 1024 def mycoroutine(func): def wrapper(self): gen = func(self) work_gen = next(gen) def fun(): result = next(work_gen) try: gen.send(result) except StopIteration: pass _thread.start_new_thread(fun, ()) return wrapper class IndexHandler(tornado.web.RequestHandler): @tornado.web.asynchronous @mycoroutine def get(self): arg = 10 # 假設(shè)請(qǐng)求的參數(shù) result = yield long_work(arg) self.finish(f'
Index {result}
') class SyncHandler(tornado.web.RequestHandler): def get(self): self.write('SyncHandler
') def make_app(): return tornado.web.Application([ (r'/', IndexHandler), (r'/sync', SyncHandler) ]) if __name__ == '__main__': app = make_app() app.listen(8888) tornado.ioloop.IOLoop.current().start() 小白 python tornado 也不熟 剛試著用 需要配置兩個(gè)端口來保證 一個(gè)端口掛了另一個(gè)會(huì)起來 服務(wù)不會(huì)終止 通過 nginx 要怎么配置? 要哭了 不會(huì)做 很尷尬
比如說要等某個(gè)耗時(shí)操作的結(jié)果, 該怎么寫?
網(wǎng)上看了半天例子, 照著做了做, 貌似行不通
class AsyncTaskHandler(tornado.web.RequestHandler): @tornado.web.asynchronous @tornado.gen.coroutine def get(self, *args, **kwargs): resp = yield tornado.gen.Task(self.do_something) self.finish(resp) @tornado.gen.coroutine def do_something(self, *args, **kwargs): time.sleep(10) return {'message': 'OKOK'}
按網(wǎng)上的方法更改了配置后,單純本地打開 html 文件是顯示有圖片上傳的選項(xiàng)的, 但服務(wù)跑起來的方式打開的話, 就沒有了, 這是怎么回事??
記得先前有個(gè) issue 提及到 routing 的問題的,深夜翻一下 Tornado 的代碼,剛剛好遇上 update 到 v4.5多了這么一個(gè) routing 的實(shí)現(xiàn),終于有了一個(gè)官方點(diǎn)的稍微好看優(yōu)雅點(diǎn)的方式去組織 Tornado 的 Application 和 Handler 了 直接看代碼吧 https://github.com/tornadoweb/tornado/blob/master/tornado/routing.py 官方的文檔都還沒有更新Tornado 的代碼寫得挺優(yōu)雅的,很適合圍觀
看博客上面的評(píng)測,性能表現(xiàn)很不錯(cuò)。https://morepypy.blogspot.jp/2017/03/async-http-benchmarks-on-pypy3.html?m=1 UVloop 新版本也開放了對(duì) tornado 的支持。 https://github.com/Magicstack/uvloop/issues/35 看目前網(wǎng)絡(luò)上面的評(píng)測 sanic+uvloop 評(píng)測數(shù)據(jù)遙遙領(lǐng)先。 如果 pypy 支持 Python3.5 之后, pypy+uvloop+tornado 可以跑出什么樣的數(shù)據(jù)?
用下面的代碼做文件上傳,在自己電腦測試能夠成功上傳,到局域網(wǎng)其他電腦測試,顯示 finished!了,但是沒看到文件,請(qǐng)問前輩,是什么原因呢?該代碼運(yùn)行在 xp 系統(tǒng)上,上傳文件夾已設(shè)置最高權(quán)限。import tornado.ioloop import tornado.web import shutil import os class UploadFileHandler(tornado.web.RequestHandler): def get(self): self.write('''
Upload File
''') def post(self): upload_path=os.path.join(os.path.dirname(__file__),'files') #文件的暫存路徑 file_metas=self.request.files['file'] #提取表單中‘ name ’為‘ file ’的文件元數(shù)據(jù) for meta in file_metas: filename=meta['filename'] filepath=os.path.join(upload_path,filename) with open(filepath,'wb') as up: #有些文件需要已二進(jìn)制的形式存儲(chǔ),實(shí)際中可以更改 up.write(meta['body']) self.write('finished!') app=tornado.web.Application([ (r'/file',UploadFileHandler), ]) if __name__ == '__main__': app.listen(3000) tornado.ioloop.IOLoop.instance().start()
現(xiàn)在的需求是:手機(jī) app 上傳圖片->tornado 調(diào)用 c++算法庫處理->向手機(jī)返回結(jié)果。 目前遇到的問題是 c++算法庫需要耗時(shí) 1 秒左右,這樣會(huì)把整個(gè) tornado 阻塞住吧?有什么好的異步解決方法或思路嗎? 請(qǐng)問我這個(gè)需求可以用協(xié)程的方式解決嗎?還是用多進(jìn)程的方式解決?
最近在用 Python 開發(fā)一個(gè)自己的網(wǎng)站,要用到七牛做為網(wǎng)站的 storage ,但是七牛官方 sdk 不支持異步,所以打算自己寫一個(gè)異步的 sdk 。寫出來之后自己用著還可以,所以想給大家分享一下,不喜勿噴。
python version : >=3.4
github: https://github.com/free-free/tornaqiniu
doc: https://github.com/free-free/tornaqiniu
tornado 可以使用如下方式并行異步請(qǐng)求。 @gen.coroutine def get(self): http_client = AsyncHTTPClient() response1, response2 = yield [http_client.fetch(url1), http_client.fetch(url2)]
這個(gè)時(shí)候, 1,2 是同時(shí)發(fā)送出去的,也就是說使用這種方式,可以讓 n 個(gè)請(qǐng)求,同時(shí)發(fā)出去,等他們都返回了再統(tǒng)一返回。
那么我要如何保證,其中一個(gè)請(qǐng)求壞了,其余的結(jié)果依舊可用?
剛開始學(xué) tornado ,它的異常處理機(jī)制有點(diǎn)弄不明白。
寫了一個(gè)測試用的小腳本,期望遇到 404 的時(shí)候能夠觸發(fā)我自己聲明的 write_error 函數(shù),然而 write_error 并沒有生效,輸出的是 tornado 默認(rèn)的 404 頁面。
代碼如下: #!/bin/env python3.5 #coding:utf-8 import os import tornado.httpserver import tornado.ioloop import tornado.options import tornado.web from tornado.options import define, options define("port", default=8000, help="端口", type=int) class BaseHandler(tornado.web.RequestHandler): def write_error(self, stat, **kw): self.write('Func write_error !') class IndexHandler(BaseHandler): def get(self): self.write('hello') handlers = [ (r'/index', IndexHandler), ] settings = { 'template_path': os.path.join(os.path.dirname(__file__), "templates"), 'static_path': os.path.join(os.path.dirname(__file__), 'static'), } if __name__ == '__main__': tornado.options.parse_command_line() app = tornado.web.Application(handlers=handlers, **settings) http_server = tornado.httpserver.HTTPServer(app) http_server.listen(options.port) print(options.port) tornado.ioloop.IOLoop.instance().start()
然后去 google 了一下,把 BaseHandler 成了這樣,但是 404 的時(shí)候還是返回了默認(rèn)的 404 頁面: class BaseHandler(tornado.web.RequestHandler): def _handle_request_exception(self, e): self.write_error(404) def send_error(self, stat, **kw): self.write_error(404) def write_error(self, stat, **kw): self.write('Func write_error !')
試了下使用 tornado 的 coroutine 和自已定義的一個(gè) decorator 一起使用,但發(fā)現(xiàn)不會(huì)在 yield 出掛起,而是向上返回。 就是說,如果有多層嵌套的話,在運(yùn)行到最底層的 yield 處之后,程序不會(huì)運(yùn)行 yield 之后的代碼,而是向上返回一個(gè)空的 future ,而且上層代碼也不會(huì)執(zhí)行 yield 之后的代碼而是繼續(xù)向上返回。 不知道有沒有大神能給出一個(gè)例子,將 coroutine 和自定義的裝飾器一起使用的例子,或者說能指出怎么使用。謝謝
下面是 tornado.httpclient.AsyncHTTPClient 類的 fetch() 方法的源代碼。我沒有在里面找到任何"fetch"的動(dòng)作,它是怎么實(shí)現(xiàn) “ Executes a request, asynchronously returning an HTTPResponse ”的?
完整代碼在: https://github.com/tornadoweb/tornado/blob/master/tornado/httpclient.py def fetch ( self , request , callback = None , raise_error = True , ** kwargs ): """Executes a request, asynchronously returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional kwargs: ``HTTPRequest(request, **kwargs)`` This method returns a `.Future` whose result is an `HTTPResponse`. By default, the ``Future`` will raise an `HTTPError` if the request returned a non-200 response code (other errors may also be raised if the server could not be contacted). Instead, if ``raise_error`` is set to False, the response will always be returned regardless of the response code. If a ``callback`` is given, it will be invoked with the `HTTPResponse`. In the callback interface, `HTTPError` is not automatically raised. Instead, you must check the response's ``error`` attribute or call its `~HTTPResponse.rethrow` method. """ if self . _closed : raise RuntimeError ( "fetch() called on closed AsyncHTTPClient" ) if not isinstance ( request , HTTPRequest ): request = HTTPRequest ( url = request , ** kwargs ) else : if kwargs : raise ValueError ( "kwargs can't be used if request is an HTTPRequest object" ) # We may modify this (to add Host, Accept-Encoding, etc), # so make sure we don't modify the caller's object. This is also # where normal dicts get converted to HTTPHeaders objects. request . headers = httputil . HTTPHeaders ( request . headers ) request = _RequestProxy ( request , self . defaults ) future = TracebackFuture () if callback is not None : callback = stack_context . wrap ( callback ) def handle_future ( future ): exc = future . exception () if isinstance ( exc , HTTPError ) and exc . response is not None : response = exc . response elif exc is not None : response = HTTPResponse ( request , 599 , error = exc , request_time = time . time () - request . start_time ) else : response = future . result () self . io_loop . add_callback ( callback , response ) future . add_done_callback ( handle_future ) def handle_response ( response ): if raise_error and response . error : future . set_exception ( response . error ) else : future . set_result ( response ) self . fetch_impl ( request , handle_response ) return future def fetch_impl ( self , request , callback ): raise NotImplementedError ()
https://github.com/pkwenda/Blog/labels/elasticsearch ------ 測試已經(jīng)完成,還有 scroll 、reindex 、等遷移數(shù)據(jù)相關(guān)的以及 es 遷移過程匯總多數(shù)據(jù)源處理等待整理
索引的時(shí)候,可以自定義分詞,添加 html_strip 過濾掉 html 標(biāo)簽不分詞,但文檔的 _source 里面還是會(huì)有 html 標(biāo)簽,因?yàn)樾枰龈吡?命中的高亮文本是從 _source 里面取的,如果命中的文本前后有 html 標(biāo)簽,則返回的高亮文本里也有可能會(huì)有標(biāo)簽,并且標(biāo)簽還有可能被截?cái)?這就導(dǎo)致返回給前端無法準(zhǔn)確展示。數(shù)據(jù)使用 Logstash pipeline 從 mysql 同步到 es,目前想到的一個(gè)方案是在 pipeline 里加了 mutate,把所有 html 標(biāo)簽全部過濾掉,這樣返回給前端的就只是純文本,粗略看了下索引數(shù)據(jù),基本滿足要求。 如果不在數(shù)據(jù)寫入 es 前過濾掉標(biāo)簽,有沒有辦法在搜索返回時(shí)過濾掉標(biāo)簽? mutate 只是把 html 標(biāo)簽過濾掉,文檔里還有些 url 鏈接(并可能帶 url 參數(shù)),好像也會(huì)被索引到,有沒有辦法不索引 url 及后面的 url 參數(shù)。 以上,一般搜索引擎里如何實(shí)現(xiàn)把 html 標(biāo)簽過濾掉,同時(shí)返回的數(shù)據(jù)能夠提供前端友好地展示?
PUT _all { "settings": { "analysis": { "analyzer": { "my_analyzer": { "tokenizer": "ngram_one_word" } }, "tokenizer": { "ngram_one_word": { "type": "ngram", "min_gram": 1, "max_gram": 16, "filter": [ "lowercase" ] } } } } } { "error": { "root_cause": [ { "type": "invalid_index_name_exception", "reason": "Invalid index name [_all], must not start with '_', '-', or '+'", "index_uuid": "_na_", "index": "_all" } ], "type": "invalid_index_name_exception", "reason": "Invalid index name [_all], must not start with '_', '-', or '+'", "index_uuid": "_na_", "index": "_all" }, "status": 400 }
不想一個(gè)一個(gè)設(shè)置,求解。
另外問一下能像以前那樣 在 elasticsearch.yml 里面全局設(shè)置嗎 ?
elasticsearch 配置中文教程
寫了一篇 elasticsearch 配置的教程給初學(xué)者。Elasticsearch 的配置選項(xiàng)繁多,這篇文章里總結(jié)了一下剛剛開始設(shè)置的時(shí)候需要配置的基本選項(xiàng)和它們的含義。
如果你覺得有幫助請(qǐng)收藏和分享讓更多人看到呀
正文點(diǎn)這里 => elasticsearch.yml 配置中文教程
1.業(yè)務(wù)方本身系統(tǒng)的故障,出現(xiàn)大量數(shù)據(jù)的丟失 2.業(yè)務(wù)高速發(fā)展產(chǎn)生增減字段或者修改分詞算法等相關(guān)的需求 3.業(yè)務(wù)冷啟動(dòng)會(huì)有一次性導(dǎo)入大批量數(shù)據(jù)的需求
以上情況需要全量索引,我看網(wǎng)上大多數(shù)是說通過別名的方式來重建,是不是只能這一種方案呢?
增量索引可以通過 canal 監(jiān)聽 binlog 日志來完成增量索引,如果全量索引的時(shí)候怎么暫停增量索引呢?
有 3 個(gè)基礎(chǔ)的小疑問,問問大佬們。 不需要參與搜索的字段,可以冗余進(jìn)索引嗎? 比如商家的地址,地址僅僅作為展示而已。還是需要再配合關(guān)系數(shù)據(jù)庫進(jìn)行組合數(shù)據(jù),這樣又得去查一次數(shù)據(jù)庫。 關(guān)聯(lián)數(shù)據(jù)是拆分到多個(gè) Index 還是一個(gè)大寬表更合適。如商家有個(gè) goods 數(shù)組嵌套字段,把商品信息全存進(jìn)去。 關(guān)聯(lián)問題 2,商品也會(huì)參與搜索。如何對(duì) goods 字段進(jìn)行排序呢?
搜了很久都搜不到咋關(guān)閉,硬盤快被這些 gc.log 填滿了,另外,關(guān)閉了對(duì) es 性能有影響嗎?
先謝為敬
POST car_record/_delete_by_query{ "query": { "bool": { "must": { "range": { "verifyTime": { "gte": "2020-04-01", "lte": "2020-05-01", "format": "yyyy-MM-dd" } } } } } }
剛學(xué)習(xí) es,這個(gè)問題困擾了我很久。。求大佬救救我 查詢語句 { "query": { "term": { "memberid": "2136476" } }, "aggs": { "group": { "terms": { "field": "meetingid", "order": { "addtime": "desc" } }, "aggs": { "result": { "top_hits": { "_source": [ "meetingid", "memo", "addtime" ], "size": 1, "sort": { "addtime": { "order": "desc" } } } }, "addtime": { "max": { "field": "addtime" } } } } } }
我想要獲取_source 的值
最后獲取到這一步后卡住了,debug 了一下發(fā)現(xiàn)有一個(gè) SearchHit 的值,但我用 getProperty()獲取不到,求解答 SearchResponse response = client.search(request).actionGet(); Aggregations aggregations = response.getAggregations(); Aggregation a = aggregations.get("meeting"); Terms teamSum= (Terms)a; for(Terms.Bucket bucket:teamSum.getBuckets()){ Aggregation aggregation = bucket.getAggregations().get("result"); }
org.springframework.data.elasticsearch.repository 的ElasticsearchRepository 方法命名查詢 好像是默認(rèn)只返回 10 條,問下這個(gè)限制要怎么去掉
類似 select couponTypeId,counterCode,count(*) from table group by couponTypeId,counterCode
下面是是單條件聚合
POST coupon_statistics_record/_search { "aggs": { "group_by_couponTypeId": { "terms": {"field": "couponTypeId.keyword"} } } }
現(xiàn)在的數(shù)據(jù)量是 1.5kw 左右,內(nèi)容是 20 個(gè)以內(nèi)的漢字,使用的 ik-skart 分詞器。
index test 的 mapping 定義: "content": { "type": "text", "analyzer": "ik_smart" }, "title": { "type": "text", "analyzer": "ik_smart" }
測試分詞:
http://127.0.0.1:9200/_analyze
提交參數(shù): { "text": "中國美國英國", "analyzer": "ik_smart" }
返回 { "tokens": [ { "token": "中國", "start_offset": 0, "end_offset": 2, "type": "CN_WORD", "position": 0 }, { "token": "美國", "start_offset": 2, "end_offset": 4, "type": "CN_WORD", "position": 1 }, { "token": "英國", "start_offset": 4, "end_offset": 6, "type": "CN_WORD", "position": 2 } ] }
_search 測試一下索引 test
get body { "size": 20, "query": { "match": { "content": "廣州人" } } }
返回: { "took": 0, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 1, "max_score": 0.84268904, "hits": [ { "_index": "dcc-speechcrafts", "_type": "dcc-speechcraft", "_id": "AXIyjmXuVhRXxkRgwNlT", "_score": 0.84268904, "_source": { "title": "", "content": "qefdygyrfh 廣州人" } } ] } }
第二次_search 測試一下
get body { "size": 20, "query": { "match": { "content": "廣州" } } }
返回: { "took": 1, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 0, "max_score": null, "hits": [] } }
問題,我那條記錄內(nèi)容包含 廣州人 這三個(gè)字,為什么分別用 廣州人 和 廣州 兩個(gè)詞去查詢,一次有結(jié)果,一次沒結(jié)果呀?按道理用 廣州 去查詢應(yīng)該也是返回一樣的結(jié)果的呀,這什么問題?
elasticsearch 5.6.16
logstash 同步 mysql 增量數(shù)據(jù)到 elasticsearch,除了把 mysql 的主鍵 id 賦值給 index.document_id 外,有沒有其它辦法避免數(shù)據(jù)重復(fù)的問題。如果只有這種辦法,那 mysql 的自增 id,對(duì)于 es 的文檔索引效率等有什么影響嗎?
數(shù)字貨幣的最小單位是 1 乘 10 的負(fù) 8 次方,即 0.00000001,出現(xiàn)任何比小數(shù)點(diǎn)后 8 位小的則自動(dòng)截取小數(shù)點(diǎn)后 8 位,不采用四舍五入的方法 交易所 MGD/BTC 這兩種數(shù)字貨幣的交易 假設(shè): 甲以 1 個(gè) MGD=0.000494BTC 的價(jià)格購買 16000 個(gè) MGD
即買入下單: 價(jià)格(BTC)0.000494 數(shù)量( MGD ) 16000 預(yù)計(jì)成交額 7.904BTC ( 0.000494* 16000 ) 下單時(shí),系統(tǒng)凍結(jié) 7.904 個(gè) BTC 用于購買 16000 個(gè) MDG, 這筆訂單在撮合交易系統(tǒng)里分別與乙和丙完成成交 乙、價(jià)格 0.000494 數(shù)量 11057.9159 成交 5.4626104546 截取八位 5.46261045 丙、價(jià)格 0.000494 數(shù)量 4942.0841 成交 2.4413895454 截取八位 2.44138954
則乙獲得 5.46261045 個(gè) BTC ;丙獲得 2.44138954 個(gè) BTC,雙方共獲得 7.90399999 而甲下單以后被凍結(jié) 7.904 個(gè) BTC 并成功購買 16000 個(gè) MGD 那么這 7.904-7.90399999=0.000000001 的誤差如何來處理?
我們的方法是算作交易所的收益,但是否有可能某一種交易的情況下,需要交易所補(bǔ)貼類似這樣 0.00000001 的情況? 而且交易數(shù)據(jù)是用戶可查的,對(duì)于甲來說,兩次交易分別顯示花出 5.46261045 個(gè) BTC 和 2.44138954 個(gè) BTC,那么甲是否會(huì)找交易所問他的 0.00000001 個(gè) BTC 哪里去了。
TimescaleDB 基于 PostgreSQL,專門用于存儲(chǔ)時(shí)序( time series )類型數(shù)據(jù)。時(shí)序類型的數(shù)據(jù),本來就會(huì)越用量越多,這個(gè)壓縮功能看起來效果不錯(cuò): https://docs.timescale.com/latest/using-timescaledb/compression 實(shí)際壓縮效果: https://twitter.com/thursdayschild/status/1239918746598334465
一個(gè)基于 Postgres 的時(shí)間序列( time-series )數(shù)據(jù)庫:https://www.timescale.com/ 這是一個(gè)用各種時(shí)間維度查詢紐約市出租車出行數(shù)據(jù)的例子: https://docs.timescale.com/v0.9/tutorials/tutorial-hello-nyc 如果你的數(shù)據(jù)類型就是各種數(shù)值 + 時(shí)間(比如各種計(jì)費(fèi)數(shù)據(jù)或是來自傳感器的數(shù)據(jù)),那么 Timescale 會(huì)是一個(gè)很值得嘗試的方案。
難受啊,剛剛收到 leancloud 的通知郵件。強(qiáng)制所有應(yīng)用綁定域名。
只能 gitment 和 disqus,2 選一了。