Comments (10)
I wonder if it's because of Wordpress's wp_remote_post
here. Nothing else should cause process creation. Is there any information from them was it because of this call? I'll also dig around
from applicationinsights-wordpress.
Support was support and seemed to me that guy was far from bits and bytes. So, there's no information that can help us. I asked him for technical guys but wellโฆ Still, maybe I have something for you.
I went through PHP configuration and I saw it is running in CGI mode. It should mean that every request gets its own PHP process. I think this is why they have page where suggested number of requests per hosting package are listed.
As my blog uses caching then requests to posts and other pages are usually fast - 0.2-0.5s and perhaps this is why it is able to survive more load than I have ever expected. Although cache is used it is served by WordPress plugin and it means that ApplicationInsights works also for cached requests (I suppose).
There's one option to make the number of requests to pile and this can happen with server-side requests to other sites when network connection is slow or when server on the other end doesn't respond fast enough. I mean, if request to external machine takes usually let's say one second then it's suddenly 8 seconds and requests start piling as they are waiting for response.
If this is the case then I can think about few ways how to solve the problem:
-
Add request timeout as configuration option so users with busy sites can set it to some small value. If timeout comes then your plugin just fails clean. This way PHP processes cannot pile up so easily and go through the limits of smaller hosting packages.
-
Send information to Application Insights service using JavaScript. Just prepare request data and let browser do the job. I'm not very much sure about this option as server-side page loading time is not so accurate anymore. But then there's no network dependencies on your plugin level.
-
Mix of two above. If request to Application Insights times out then let's automatically switch to JavaScript option.
Not sure if point 2 is valid and has any meaning but it looks like a good idea to break one dependency to external resource.
from applicationinsights-wordpress.
@gpeipman I think this may be the case I don't think sending to Application Insights will take seconds, but sometimes it may be up to a second (with slower networks).
One solution may be to send request and do not wait for response. But wp_remote_post
doesn't seem to allow for this. Alternative is to curl
in separate process, but it wouldn't address your problem.
Another issue suggest to implement some batching and back off logic: microsoft/ApplicationInsights-PHP#50
So perhaps one good solution will be to start background process that uploads data and all requests just dump information to specific file location.
Does HostGator allow some writeable file system location and start separate processes?
from applicationinsights-wordpress.
Yes, of course, otherwise it would be close to impossible to use WordPress normally.
My simple shared hosting package supports also cron jobs, so I think it has everything needed.
If it is okay for Application Insights then it's not a problem when cron job runs once or twice per hour.
from applicationinsights-wordpress.
@gpeipman I was thinking more like once a minute. Otherwise the delay for data upload will be too high. So maybe php script with the infinite loop and sleep. Not sure if it's a best practice in PHP.
Would you be interested to contribute? These SDKs (PHP and wordpress) are community supported, not officially maintained. But I'll be happy to review and help where I can.
from applicationinsights-wordpress.
Hosting guys usually doesn't like those endless scripts and some of them may have also guarding systems that kill processes that have been up for too long. To get rid of this there are two options:
- cron job with one minute interval
- upload script called from some external process using wget, curl etc
If cron job happens frequently it's possible that hosting takes it as a sign of something suspicious. In this means it would be important even there to have small request timeouts.
To contribute I have to understand first how the code works. I know PHP language and some internals of WordPress but I haven't written anything serious on PHP more than ten years. But let's try.
from applicationinsights-wordpress.
Contributing instructions are straightforward: https://github.com/Microsoft/ApplicationInsights-WordPress/blob/master/CONTRIBUTING.md You can use docker or just host a local version of wordpress.
This line constructs the client:
https://github.com/Microsoft/ApplicationInsights-WordPress/blob/7b782fd771d7df70874aaad6cba0d50f3d8409a2/src/Server_Instrumentation.php#L23
Constructor of TelemetryClient accepts channel as an argument: https://github.com/Microsoft/ApplicationInsights-PHP/blob/fd82b5e1c3b2002b63ac85fad69b3aae2c4c3620/ApplicationInsights/Telemetry_Client.php#L26-L30 So you can create a custom copy of channel in this repository that will implement the same methods as this channel: https://github.com/Microsoft/ApplicationInsights-PHP/blob/fd82b5e1c3b2002b63ac85fad69b3aae2c4c3620/ApplicationInsights/Channel/Telemetry_Channel.php#L221-L230
And method send
will do some advanced logic. If long running scripts is bad - maybe store some last running time in server variables or in file system. And run script only when difference in time is more than couple minutes. So send
will save data to file system, check the time difference and if much time passed - run a script to read data from file storage and send them to Application Insights.
from applicationinsights-wordpress.
How this note can help you get started. Let me know if you need more help. And don't hesitate to point on unclear contributing docs or code structure. We want to make contributions easy and straightforward
from applicationinsights-wordpress.
@SergeyKanzhelev I am php dev and would like take care of this issue.
from applicationinsights-wordpress.
I got something done and it even works. Request parameters needed by trackRequest() method are saved to file and there's cron job that goes through all saved files, sends data to Application Insights and deletes files. As I'm not WordPress expert I don't have much idea how to fit it to this plugin the way that others can also use it.
Anyway, if somebody needs urgent solution then feel free to ping me while I try to figure out how to make this functionality as integral part of plugin.
from applicationinsights-wordpress.
Related Issues (20)
- Application Insights JavaScript Updated HOT 3
- Still being developed? Abandoned? Still working (in WP 4.8.x)? HOT 1
- Regex not working on a client instrumentation Page name HOT 1
- Is this plugin now actively maintained? HOT 3
- Error to active plugin on WordPress 4.2.2 HOT 5
- I get HTTP 500 after some days working in production HOT 1
- 500 error: Class 'ApplicationInsights\WordPress\Settings' not found HOT 3
- I cannot activate the plugin HOT 6
- Apparent Issue with Decoupled Wordpress Installations HOT 1
- Execution time sent in seconds and not miliseconds HOT 1
- Does the Application Insights Plugin Work in Microsoft Azure Government
- Any plans to upgrade this plugin to support latest WordPress version HOT 3
- Not working as per instructions in readme.txt HOT 2
- Error on line 10
- Functions are called incorrectly in Server_instrumentation.php
- Failed opening required 'vendor/autoload.php' HOT 1
- Telemetry send but errors generated in php HOT 1
- Memory usage HOT 2
- PHP Fatal error: Uncaught TypeError: Argument exceptionHandler HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from applicationinsights-wordpress.