influxdata / influxdb-php

influxdb-php: A PHP Client for InfluxDB, a time series database
http://influxdb.com
MIT License
432 stars 125 forks source link

any info about udp vs default driver? #47

Open boynet opened 8 years ago

boynet commented 8 years ago

is there any preferred way? thanks

boynet commented 8 years ago

p.s pretty sure you need to put some warning on the examples withexec('date +%s%N') it has bad performance. at least for me in ubuntu 16 this code is taking 1.5158290863037 sec to complete

for($x=0;$x<1000;$x++) {
            exec('date +%s%N');
}
gianarb commented 8 years ago

Well UDP vs TPC is a very good topic.

UDP is really fast but you have not guarantee about your point, because the protocol have not this kind of check if you are sending CPU point you can not be sure that all your point will be in influxdb. TPC has this check but it's slow.

I have two different strategy. 1) Are you using a agent on your server to collect local data like telegraf? In this case you can send udp data to the agent because between your local network the probability to lose package is low and you will send bulk of point via TPC with the collector, in this way your application will be fast.

2) You are not using an agent. In this case depends, if you can not accept to miss points use TCP.

In this article I spoke about another library but there is a bench UDP vs TPC http://gianarb.it/blog/InfluxDB-and-PHP

akalongman commented 4 years ago

@gianarb How to send data to a locally started Telegraf agent?

gianarb commented 4 years ago

Hello @akalongman , telegraf has an input plugin called http_listener

https://github.com/influxdata/telegraf/tree/master/plugins/inputs/http_listener_v2

This plugin exposes a compatible API layer with InfluxDB. You can change the client URL to hit the one exposed by the telegraf plugin and everything should just work as before but passing via Telegraf!

akalongman commented 4 years ago

@gianarb thank you. Is it possible to use UDP? I do not want to add network overheads on my application

gianarb commented 4 years ago

Hello

Yes! Same concept but with a different telegraf input plugin

https://github.com/influxdata/telegraf/blob/master/plugins/inputs/socket_listener/README.md

Il Gio 9 Gen 2020, 10:57 Avtandil Kikabidze notifications@github.com ha scritto:

@gianarb https://github.com/gianarb thank you. Is it possible to use UDP? I do not want to add network overheads on my application

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/influxdata/influxdb-php/issues/47?email_source=notifications&email_token=AAMOAO44JPR3BNENHCDYVK3Q43YG7A5CNFSM4CFR4632YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIPWJ3Y#issuecomment-572482799, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMOAO6647ZQKWJIZDAFHRLQ43YG7ANCNFSM4CFR463Q .