简体   繁体   中英

How to run periodic process in Heroku Java app that makes web requests

From my understanding of the Heroku platform, they allow only one dyno per app that can handle HTTP requests. Within a Java app, my goal is to have a periodic process run once or twice a day that gets information from Facebook servers and processes it accordingly. If a background worker dyno can't handle web requests, then how should I go about writing a reoccurring process within the web dyno?

In this sense, "handle HTTP requests" refers to the listen side of the connection not the send side. On Heroku, an application can have a single web process* that listens for HTTP connections and many other processes that initiate / send HTTP requests (or connect to other non-HTTP systems).

*Note: You can allocate as many Dynos as you want, to run each process.

To run a process that periodically makes requests to an external service (like Facebook) you can use the Heroku Scheduler Add-on . Then you could either store the results in one of the many relational or NoSQL data-storage add-ons or possibly send the results to other processes via a messaging add-on like CloudAMQP .

If the platform is limiting you, why use it?
There are other platforms that will let you perform this. You can easily deploy java applications to the cloud using OpenShift and then you use java API with no limitations what soever as far as I know.
OpenShift is also using git, same way Heroku does.
They are both PaaS, so the concept is quite the same, and I think it will be easy for you to try out OpenShift.
And you can also check Google App Engine to see if it has such limitations.
Sorry for not helping you with the specific question, I simply know that at least "one competitor" does not have such a limitation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM